2 Replies Latest reply on Nov 14, 2016 7:36 AM by Voverrr Mironoff

    How to get in macro the quantity of cut-list items?

    Voverrr Mironoff


      At first, excuse me for my barbarian English and russian interface.

      I have the welded  multibody part. I made the drawing and want to get the number of cut-list items in part in view. As you can see different cut-list items can contain as one body and several bodies.

      I can get the number of bodies with command swView.GetBodiesCount.

      But I want to find the count of unique bodies(i.e. items). In my case this count =17.


      Thank you.

        • Re: How to get in macro the quantity of cut-list items?
          Ivana Kolin

          Please try this

          Option Explicit
          Sub main()
              Dim swApp                                     As SldWorks.SldWorks
              Dim swModel                                   As SldWorks.ModelDoc2
              Dim swSelMgr                                  As SldWorks.SelectionMgr
              Dim swView                                    As SldWorks.View
              Dim swDrawModel                               As SldWorks.ModelDoc2
              Dim swFeatMgr                                 As SldWorks.FeatureManager
              Dim swFeat                                    As SldWorks.Feature
              Dim swBodyFolder                              As SldWorks.BodyFolder
              Dim FeatType                                  As String
              Dim FeatTypeName                              As String
              Dim counter                                   As Integer
              Set swApp = Application.SldWorks
              Set swModel = swApp.ActiveDoc
              Set swSelMgr = swModel.SelectionManager
              Set swView = swSelMgr.GetSelectedObject6(1, -1)
              Set swDrawModel = swView.ReferencedDocument
              Set swFeatMgr = swDrawModel.FeatureManager
              Set swFeat = swDrawModel.FirstFeature
              Do While Not swFeat Is Nothing
                  FeatType = swFeat.Name
                  FeatTypeName = swFeat.GetTypeName2
                  If FeatTypeName = "CutListFolder" Then
                      Set swBodyFolder = swFeat.GetSpecificFeature2
                      swBodyFolder.SetAutomaticCutList True
                      swBodyFolder.SetAutomaticUpdate True
                      counter = counter + 1
                  End If
                  Set swFeat = swFeat.GetNextFeature
              MsgBox counter
          End Sub