AnsweredAssumed Answered

Why macro for cut-Extrude fails?

Question asked by Deepak Kumar on Oct 27, 2020
Latest reply on Oct 27, 2020 by Eddy Alleman

I have recorded a macro for simple triangular cut extrude. This macro runs for some parts but fails for some others with different dimension values. Manually it is successfully getting cut.

   Can someone please help me out of this problem?

Thanks in advance!

here is the recorded macro -Cut Extrude Sketch

Option Explicit

    Dim swApp As SldWorks.SldWorks

    Dim swModel As SldWorks.ModelDoc2
    Dim swEquationMgr As Object
    Dim boolstatus As Boolean
    Dim Part As Object
    Dim longstatus As Long, longwarnings As Long

boolstatus = Part.Extension.SelectByID2("Mold Parting Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True

Set skSegment = Part.SketchManager.CreateLine(-0.204086, -0.152671, 0#, -0.204086, -0.218434, 0#)
Set skSegment = Part.SketchManager.CreateLine(-0.204086, -0.218434, 0#, -0.048089, -0.218434, 0#)
Set skSegment = Part.SketchManager.CreateLine(-0.048089, -0.218434, 0#, -0.204086, -0.152671, 0#)
Part.SetPickMode
Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("Right Plane", "PLANE", -1.44278008366894E-03, -0.230669261721114, 3.31726000000003E-02, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Point3", "SKETCHPOINT", -0.048088891473147, -0.21843421611076, 0, True, 0, Nothing, 0)

Set myDisplayDim = Part.AddDimension2(-2.51481809537316E-02, -0.249021830136647, -0.024384)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Line1", "SKETCHSEGMENT", -0.203321032654525, -0.201611028396521, 2.57487000000007E-02, False, 0, Nothing, 0)
Set myDisplayDim = Part.AddDimension2(-0.311907062446424, -0.181729079279695, -0.024384)
Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("Line2", "SKETCHSEGMENT", -0.144161910010995, -0.218150300551579, 2.50501996900002E-02, False, 0, Nothing, 0)

Set myDisplayDim = Part.AddDimension2(-0.143507460901863, -0.243673815807726, -0.024384)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Line2@Sketch5", "EXTSKETCHSEGMENT", -2.21071511578854E-02, -0.13335, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Line2", "SKETCHSEGMENT", -8.19892446434595E-02, -0.218477525106145, 2.50501996900002E-02, True, 0, Nothing, 0)
Set myDisplayDim = Part.AddDimension2(-0.123873987627905, -0.171029964694078, -0.024384)

 

boolstatus = Part.Extension.SelectByID2("Equations", "EQNFOLDER", 0, 0, 0, False, 0, Nothing, 0)
Set swEquationMgr = Part.GetEquationMgr()
swEquationMgr.Add -1, """D1@Sketch7""= ""Gate Width""*1.75"

boolstatus = Part.Extension.SelectByID2("Equations", "EQNFOLDER", 0, 0, 0, False, 0, Nothing, 0)
Set swEquationMgr = Part.GetEquationMgr()
swEquationMgr.Add -1, """D2@Sketch7""= ""Runner Width""*0.75"

boolstatus = Part.Extension.SelectByID2("Equations", "EQNFOLDER", 0, 0, 0, False, 0, Nothing, 0)
Set swEquationMgr = Part.GetEquationMgr()
swEquationMgr.Add -1, """D3@Sketch7""= ""D1@Sketch7"""

boolstatus = Part.Extension.SelectByID2("Equations", "EQNFOLDER", 0, 0, 0, False, 0, Nothing, 0)
Set swEquationMgr = Part.GetEquationMgr()
swEquationMgr.Add -1, """D4@Sketch7""= ""Runner Width"""

Part.ForceRebuild3 (True)

 

boolstatus = Part.Extension.SelectByID2("Boss-Extrude5", "SOLIDBODY", -3.93446666649808E-02, -0.149689901400876, -2.43840000001683E-02, True, 8, Nothing, 0)

Set myFeature = Part.FeatureManager.FeatureCut4(False, False, False, 9, 1, 0.00254, 0.00254, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, False, True, False, True, True, False, 0, 0, False, False)
Part.SelectionManager.EnableContourSelection = False
Part.ClearSelection2 True

Outcomes