1 Reply Latest reply on Aug 23, 2013 2:55 PM by Keith Rice

    Show/hide BOM table

    Jela Rose Tano-An

      I made three(3) bom tables and I want to show only one(1) table.

      I recorded a macro but it only records the selecting of bom table.


      Is there a way to show/hide the bom table?

      Also, move the column and rename it using macro?


      Thanks in advance.

        • Re: Show/hide BOM table
          Keith Rice

          Hi Jela,


          This code traverses all BOM tables on the current sheet. For each table, it switches the first two columns, and then hides the table. Hopefully you can use it to achieve your goals.


          If you are not familiar with macros, I would recommend you watch the free videos at my web site (see link below). You will need to have an understanding of programming, the SolidWorks API Help, and the SolidWorks Object Model if you want to become proficient with the API.




          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

          Dim swDraw As SldWorks.DrawingDoc

          Dim swView As SldWorks.View

          Dim swTableAnn As SldWorks.TableAnnotation

          Dim swAnn As SldWorks.Annotation

          Dim vTableAnns As Variant

          Dim i As Integer


          Sub main()

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Set swDraw = swModel

              Set swView = swDraw.GetFirstView

              vTableAnns = swView.GetTableAnnotations

              If IsEmpty(vTableAnns) = False Then

                  For i = 0 To UBound(vTableAnns)

                      Set swTableAnn = vTableAnns(i)

                      If swTableAnn.Type = swTableAnnotation_BillOfMaterials Then

                          swTableAnn.MoveColumn 0, swTableItemInsertPosition_After, 1

                          Set swAnn = swTableAnn.GetAnnotation

                          swAnn.Select3 False, Nothing

                          swApp.RunCommand swCommands_Hide_Table, Empty

                      End If

                  Next i

              End If

          End Sub





          SolidWorks API Video Tutorials