8 Replies Latest reply on Aug 18, 2018 12:13 PM by Patrik MacHalec

    API: BOM Collapse All

    Chris Christy

      I am using Indented Boms with Detailed Cut-lists to use for a welded assembly of sub weldments. As such when I insert a bom it has all the subweldments expanded. I would prefer to have them all collapse and then dissolve just the ones I need to dissolve. I know I can do this manually for each subweldment, but is there a way to collapse them all at the same time through the API? I haven't had any luck looking for it yet.

       

      Chris C.

        • Re: API: BOM Collapse All
          Don Carter

          I too would be interested in a macro that will fully collapse an indented BOM.  Some of our BOMs can approach 1000 rows long; collapsed, they are usually less than 50 rows long.

            • Re: API: BOM Collapse All
              Amen Allah Jlili

              It shouldn't be hard to modify this:

              This example shows how to dissolve and restore a subassembly in a BOM table.

              '-----------------------------------------------------------------------------
              ' Preconditions:
              ' 1. Open install_dir\samples\tutorial\assemblyvisualize\food_processor.sldasm.
              ' 2. Select File > Make Drawing from Assembly.
              ' 3. Click OK.
              ' 4. Drag one or more views onto the drawing.
              ' 5. Ensure that the specified template exists.
              '
              ' Postconditions:
              ' 1. Inserts an indented BOM table in the drawing.
              ' 2. Dissolves the blade shaft subassembly.
              ' 3. After the macro stops, press F5 to restore the blade 
              '    shaft subassembly.
              '
              ' NOTE: Because this document is used by a SOLIDWORKS
              ' online tutorial, do not save any changes when
              ' closing it.
              '-----------------------------------------------------------------------------
              Dim swApp As SldWorks.SldWorks
              Dim Part As SldWorks.ModelDoc2
              Dim swModelDocExt           As SldWorks.ModelDocExtension
              Dim swDrawing               As SldWorks.DrawingDoc
              Dim swView                  As SldWorks.View
              Dim boolstatus As Boolean
              Dim swBOMAnnotation         As SldWorks.BomTableAnnotation
              Dim AnchorType              As Long
              Dim BomType                 As Long
              Dim Configuration           As String
              Dim TableTemplate           As String
              Option Explicit
              Sub main()
                  Set swApp = Application.SldWorks
                  Set Part = swApp.ActiveDoc
                  Set swDrawing = Part
                  Set swModelDocExt = Part.Extension
              
                  boolstatus = swDrawing.ActivateView("Drawing View1")
                  Set swView = swDrawing.ActiveDrawingView
                  AnchorType = swBOMConfigurationAnchor_TopLeft
                  BomType = swBomType_Indented
                  TableTemplate = "C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\lang\english\bom-standard.sldbomtbt"
                  Configuration = ""
                  Set swBOMAnnotation = swView.InsertBomTable4(False, 0.4, 0.3, AnchorType, BomType, Configuration, TableTemplate, False, swNumberingType_Detailed, True)
                  'Dissolve blade shaft subassembly
                  boolstatus = swBOMAnnotation.Dissolve(8)
                  Stop
                  'Restore blade shaft subassembly
                  boolstatus = swBOMAnnotation.RestoreRestructuredComponents(0)
              End Sub
              
              
            • Re: API: BOM Collapse All
              Elmar Klammer

              You can start here Dissolving Multiple Sub-Assemblies??? - DASSAULT: SOLIDWORKS 3D Design - Eng-Tips  or here Quick Dissolve Subassembly (macro?)

              The dissolve process can take a long time and I didn't find it economic for large assemblies. I went another route.

              Starting with this post http://ww3.cad.de/foren/ubb/Forum2/HTML/004876.shtml

              It lists all items in a drawing that have a balloon attached. I just modified it to hide all rows in a BOM that have no balloon.

              That works okay for my applications. Only need it so often. Can't share the code, it belongs to my boss.

               

              Elmar

              • Re: API: BOM Collapse All
                Chris Christy

                None of these collapses the items in the BOM unless I am missing something. Like Don above, some of our BOMs are 500-1000 rows long and once collapsed drop to 20-40 items, which I then can go through and selectively dissolve. My issue is in trying to collapse the rows before dissolving. I haven't figured out how to accomplish that.

                  • Re: API: BOM Collapse All
                    Amen Allah Jlili

                    You should look at this method: RestoreRestructuredComponents(Index As Int) 

                    Parameters

                    RowIndex
                    1-based row index, if more than one subassembly or weldment are dissolved; 0, if only one subassembly or weldment is dissolved

                    Return Value

                    True if the subassembly or weldment is restored, false if not

                     

                    You need to invoke that method bottom up so that the index is not affected when the BOM rebuilds.

                  • Re: API: BOM Collapse All
                    Izac Roberts

                    You ever figure anything out for this?

                    • Re: API: BOM Collapse All
                      Patrik MacHalec

                      Hello,

                      has someone tried to use IBomTableAnnotation::Collapse ? I do not have SW 2018.

                      Please let us know, I am quite curious.

                      Thanks