ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
MDM. Doga Dogan21/07/2017

Hello,

I created a macro that can perform an automatic swept cut for continuous sketches, such as the letter M. Below is the code. I select the first point and line of Sketch2, insert a reference plane that is orthogonal to both of them, sketch a circle on the new plane and start a swept cut through Sketch2 with the help of the circle, which is Sketch3.

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("Point1@Sketch2", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)

boolstatus = Part.Extension.SelectByID2("Line1@Sketch2", "EXTSKETCHSEGMENT", 0, 0, 0, True, 1, Nothing, 0)

Dim myRefPlane As Object

Set myRefPlane = Part.FeatureManager.InsertRefPlane(4, 0, 2, 0, 0, 0)

boolstatus = Part.Extension.SelectByID2("Plane2", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

Dim skSegment As Object

Set skSegment = Part.SketchManager.CreateCircle(0#, -0#, 0#, 0.002731, 0.004392, 0#)

Part.ClearSelection2 True

Part.SketchManager.InsertSketch True

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("Sketch3", "SKETCH", 0, 0, 0, False, 1, Nothing, 0)

boolstatus = Part.Extension.SelectByID2("Sketch2", "SKETCH", 0, 0, 0, True, 4, Nothing, 0)

Dim myFeature As Object

Set myFeature = Part.FeatureManager.InsertCutSwept4(False, True, 0, False, False, 0, 0, False, 0, 0, 0, 0, True, True, 0, True, True, True, False)

But if I want to sketch, say, multiple letters, then the code cannot complete the swept cut since it's not a continuous path. Below is a sample image.

Inline image 1

As you can see, M can be cut but how do we normally apply the cut operation to other letters (in the manual case)? Do I need to create a perpendicular circle for each letter/discontinuous part of the sketch? How could I do this in a macro?

Thank you,

Doga