4 Replies Latest reply on Aug 29, 2018 1:35 AM by Mithilesh Kapre

    Thickening Multiple Surface Bodies

    Mike Price

      Hi all,

       

      I'm trying to thicken multiple surface bodies.

       

      I have the following, but it is not creating a thickened body.  I should be able to create a thicken from a selected surface body without selecting the face, correct?

       

      any help would be greatly appreciated.

       

          Dim i                  As Long
          Dim Part               As Object
         
          Dim boolstatus          As Boolean

          Dim vBody            As Variant

          vBody = swPart.GetBodies2(swSheetBody, True)

          For i = LBound(vBody) To UBound(vBody)
              Set swBody = vBody(i)
      '        MsgBox i

              boolstatus = Part.Extension.SelectByID2(swBody.Name, "SURFACEBODY", 0, 0, 0, False, 1, Nothing, 0)
              Dim myFeature As Object
              Set myFeature = Part.FeatureManager.FeatureBossThicken(0.000508, 1, 0, False, False, False, False)

          Next

        • Re: Thickening Multiple Surface Bodies
          Viktor Bovzdarenko

          Hi Mike,

          Try this macro:

           

          Dim swApp As SldWorks.SldWorks

          Sub main()

              Set swApp = Application.SldWorks

              Dim swModel As SldWorks.ModelDoc2: Set swModel = swApp.ActiveDoc

              Dim swPart As PartDoc: Set swPart = swModel

              Dim i As Long

              Dim vBody  As Variant: vBody = swPart.GetBodies2(swSheetBody, True)

              For i = LBound(vBody) To UBound(vBody)

                  Dim boolstatus As Boolean: boolstatus = swModel.Extension.SelectByID2(vBody(i).Name, "SURFACEBODY", 0, 0, 0, True, 1, Nothing, 0)

                  Dim swFeat As SldWorks.Feature: Set swFeat = swModel.FeatureManager.FeatureBossThicken(0.01, 0, 0, False, True, True, True)

              Next

          End Sub

           

          Regards

          Viktor

          • Re: Thickening Multiple Surface Bodies
            Andriy Wybaczynsky

            Hey guys,

             

            This doesn't seem to be working for me. I have copy and pasted the macro into a macro file and assigned a shortcut key. When I try selecting the target surface and running the macro via the shortcut key, the macro gives me an error.

             

            Any tips here? This is my first time running a macro on SW. If i'm doing something completely idiotic, that is why

             

            Thanks,

              • Re: Thickening Multiple Surface Bodies
                Mithilesh Kapre

                Try the below, one by Viktor is correct just need some tweaking.

                 

                Sub main()

                 

                Set swApp = Application.SldWorks

                 

                Dim swModel As SldWorks.ModelDoc2: Set swModel = swApp.ActiveDoc

                 

                Dim swPart As PartDoc: Set swPart = swModel

                 

                Dim i As Long

                 

                Dim vBody As Variant: vBody = swPart.GetBodies2(-1, True)

                 

                For i = LBound(vBody) To UBound(vBody)

                 

                Dim thick As Double

                thick = InputBox("Enter thickness")

                 

                Dim boolstatus As Boolean: boolstatus = swModel.Extension.SelectByID2(vBody(i).Name, "SURFACEBODY", 0, 0, 0, True, 1, Nothing, 0)

                 

                Dim swFeat As SldWorks.Feature: Set swFeat = swModel.FeatureManager.FeatureBossThicken(thick, 0, 0, False, False, True, True)

                Next

                End Sub