AnsweredAssumed Answered

Macro to trim the entities

Question asked by Ruchit Solanki on Aug 24, 2015

Hello Sir,

Ruchit Solanki Here

 

 

I have recorded a macro which is as under. It is supposed to create a circle in a sketch and a line of chord at some distance  and trim the unwanted arcs so that after trimming circle becomes a "D" shape.  Once D sketch is generated it is supposed to be extruded.

 

 

After recording a macro, when it is run again, every line of code is read from start to end but trimming opertion doesn't perform and also it shows no error. So I couldn't identify the actual problem. Please let me know the possible solutions.

 

 

 

 

thanking you

 

 

 

 

 

 

' ******************************************************************************

' C:\Users\welcome\AppData\Local\Temp\swx2260\Macro1.swb - macro recorded on 08/24/15 by welcome

' ******************************************************************************

Dim swApp As Object

 

 

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

 

 

Sub main()

 

 

Set swApp = _

Application.SldWorks

 

 

Set Part = swApp.NewDocument("C:\ProgramData\SolidWorks\SolidWorks 2013\templates\Part.prtdot", 0, 0, 0)

Set Part = swApp.ActiveDoc

Part.SketchManager.InsertSketch True

boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", -3.47123241222675E-02, 0.113728392843313, 9.92037007951012E-02, False, 0, Nothing, 0)

 

 

Dim skSegment As Object

Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, 0.025265, -0.044265, 0#)

Set skSegment = Part.SketchManager.CreateLine(-0.085901, -0.024457, 0#, 0.107731, -0.024457, 0#)

Part.SetPickMode

 

 

boolstatus = Part.Extension.SelectByID2("Line1", "SKETCHSEGMENT", -6.56893650168326E-02, -2.44566558985746E-02, 0, False, 2, Nothing, 0)

boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", -0.036491326722663, -3.41816189496616E-02, 0, True, 2, Nothing, 0)

boolstatus = Part.SketchManager.SketchTrim(4, 0, 0, 0)

 

 

boolstatus = Part.Extension.SelectByID2("Line1", "SKETCHSEGMENT", 7.01360297256643E-02, -2.44566558985746E-02, 0, False, 2, Nothing, 0)

boolstatus = Part.SketchManager.SketchTrim(4, 0, 0, 0)

 

 

Dim myFeature As Object

Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.01, 0.01, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, 0, 0, False)

 

 

End Sub

Outcomes