0 Replies Latest reply on Jun 28, 2016 3:41 PM by Tim Krell

    How to modify a cut extrude feature with the API

    Tim Krell

      I have a cut extrude feature that cuts bodies generated by a linear pattern, I can change the dimensions in the sketch used in the cut extrude feature but cannot change the bodies to cut in the cut extrude feature that the sketch cuts.  I think I should use "ModifyDefinition" but am not sure how to use it.  I thought modifying an existing feature would be easy to do!

       

      This is the code as far as I got, most of this is a recorded macro.

      Any well documented code would be greatly appreciated.

       

       

      Set swApp = Application.SldWorks
      Set swModel = swApp.ActiveDoc
      'Set Part = swApp.ActiveDoc

       

      'Change Cut Length Dimension
      Dim CutLength As Double
      CutLength = 70
      Set swDim = swModel.Parameter("D2@FingerCut(Sketch)")
      swDim.ISetUserValueIn3 swModel, CutLength, swThisConfiguration


      swModel.EditRebuild3


      'boolstatus = swModel.Extension.SelectByID2("FingerCut(Sketch)", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
      'swModel.EditSketch
      'swModel.ClearSelection2 True

       

      'boolstatus = Part.Extension.SelectByID2("D2@FingerCut(Sketch)@LinearPatternCut.SLDPRT", "DIMENSION", 7.10620075633694E-03, -7.43530343786387E-02, -1.08468921758118, 'False, 0, Nothing, 0)
      'swModel.SketchManager.InsertSketch True

       

      boolstatus = swModel.Extension.SelectByID2("Cut-Extrude29", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
      swModel.ClearSelection2 True


      'Change bodies to be cut
      boolstatus = swModel.Extension.SelectByID2("LPattern1[7]", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
      boolstatus = swModel.Extension.SelectByID2("LPattern1[15]", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)

      boolstatus = swModel.DeSelectByID("LPattern1[15]", "SOLIDBODY", 0, 0, 0)
      boolstatus = swModel.DeSelectByID("LPattern1[7]", "SOLIDBODY", 0, 0, 0)
      boolstatus = swModel.Extension.SelectByID2("LPattern1[16]", "SOLIDBODY", 0, 0, 0, True, 8, Nothing, 0)
      boolstatus = swModel.Extension.SelectByID2("LPattern1[8]", "SOLIDBODY", 0, 0, 0, True, 8, Nothing, 0)