Page 1 of 1

Macro insert hole with position mate with a sketch ?

Posted: Thu May 27, 2021 9:50 pm
by Max Han
I'm try to build a model macro to do that, insert a center rectangle sketch, then inset hole by HoleWizard5, which hole center mate with the rectangle sketch, so I can change the rectangle size to update hole position. As if I draw the hole manually, In solidworks UI, it would set the coincident automatically, but when I record the macro, this mate would not be recorded.
Is there anyway to create hole and mate with sketch ?

Re: Macro insert hole with position mate with a sketch ?

Posted: Tue Jun 01, 2021 11:19 am
by colt
Instead of hover snapping try selecting both using ctrl. Then select coincident. Macro recorder gave me this.

Code: Select all

boolstatus = Part.Extension.SelectByID2("Point3", "SKETCHPOINT", -4.79110246381096E-02, 1.79666342392911E-02, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Point1", "SKETCHPOINT", -3.81263787613125E-02, 2.67390753702125E-02, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgCOINCIDENT"