2 Replies Latest reply on Feb 12, 2015 5:29 AM by Leon Wurr

    Macro for Collecting all bends in Fold and Unfold feature

    ketan Panchal

      Dear All,

       

      Daily we are making lots of Sheet metal parts, in all the parts we have generated one sketch Called "Shear".

      from this shear Sketch we are getting shear values.(we used bounding box option but its not collecting correct values all the time)

       

      in couple of instances Team members are forgot to collect all the bends in unfold feature and Shear sketch didn't updated correctly.

       

      Can some one help me to make Macro for this feature. When i run this macro its go to Unfold feature collect all the bend and Finish that operation and regenerate it?

       

      • Most common Part attached
      • Solidworks 2012

       

      Regards,

      Ketan

        • Re: Macro for Collecting all bends in Fold and Unfold feature
          ketan Panchal

          Hey guys , any one has solution for this.

            • Re: Macro for Collecting all bends in Fold and Unfold feature
              Leon Wurr

              What is the problem with using the "Colect all bends" button?

               

              Anyway. I've recorded this macro, and it worked with some other parts I've tested, you'll probably have to add more bend names (BaseBend1, BaseBend2, etc):

               

               

              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.ActiveDoc

              boolstatus = Part.Extension.SelectByID2("BaseBend4", "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend5", "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend6", "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend7", "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend8", "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend9", "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend10", "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)

              Part.ClearSelection2 True

              boolstatus = Part.Extension.SelectByID2("", "FACE", 0.026603039259669, -1.51891999990994E-03, 1.36985194676527E-02, False, 1, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend4", "BODYFEATURE", 0, 0, 0, True, 4, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend5", "BODYFEATURE", 0, 0, 0, True, 4, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend6", "BODYFEATURE", 0, 0, 0, True, 4, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend7", "BODYFEATURE", 0, 0, 0, True, 4, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend8", "BODYFEATURE", 0, 0, 0, True, 4, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend9", "BODYFEATURE", 0, 0, 0, True, 4, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("BaseBend10", "BODYFEATURE", 0, 0, 0, True, 4, Nothing, 0)

              Part.InsertSheetMetalUnfold

              End Sub