4 Replies Latest reply on Jan 2, 2014 12:06 PM by David Watkins

    InsertBomTable3 toplevelonly not setting config

    David Watkins

      I am writing a macro based on the ""Insert and Show BOM Table in Assembly" help example that inserts a BOM into an assembly then saves it out. The code works for the swBomType_Indented and swBomType_PartsOnly enumerations but with swBomType_TopLevelOnly the configuration is set to nothing even though I am setting it.  Anyone know what i am missing? 




      Dim swApp As SldWorks.SldWorks

      Dim swModel As SldWorks.ModelDoc2

      Dim swBOMAnnotation As SldWorks.BomTableAnnotation

      Dim swBOMTable As SldWorks.BomTableAnnotation

      Dim swTable As SldWorks.TableAnnotation

      Dim swAnn As SldWorks.Annotation

      Dim activeCofig As String

      Dim TemplateName As String

      Dim BomType As Long

      Dim Configuration As String


      Const OutputPath As String = "C:\temp\"



      Sub main()


          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc


          TemplateName = "P:\SolidWorks\Templates\B-D_BOM.sldbomtbt"

          BomType = swBomType_TopLevelOnly

          Configuration = swApp.GetActiveConfigurationName(swModel.GetPathName)

          Set swBOMAnnotation = swModel.Extension.InsertBomTable3(TemplateName, 0, 1, BomType, Configuration, False, swNumberingType_Detailed, True)


          Set swTable = swBOMAnnotation

          swTable.SaveAsText OutputPath & swModel.GetTitle & " BOM" & ".xls", "|"


          Set swAnn = swTable.GetAnnotation

          swAnn.Select3 False, Nothing



      End Sub