AnsweredAssumed Answered

Why won't the API create a BOM?

Question asked by Tim Lewis on Apr 19, 2016
Latest reply on Apr 20, 2016 by Tim Lewis

I'm using the code below to try to create a BOM using the API:

 

Sub main()

    Dim swBOMTable As SldWorks.BomTableAnnotation, BOMTemplate As String

    BOMTemplate = "\\Server\path\to\bom-standard.sldbomtbt"

    Set swBOMTable = Application.SldWorks.ActiveDoc.Extension.InsertBomTable(BOMTemplate, 0, 0, _

                                                                                               swBomType_e.swBomType_TopLevelOnly, "")

End Sub

 

However, when line #5 executes, the swBOMTable is empty and no BOM is created.  This is somewhat mystifying to say the least because this is essentially the code that was created with the macro recorder when I recorded myself adding a BOM to an open SW assembly.  It seems like this should be fairly straightforward.  I believe the above code above is the recommended means of creating a BOM with the API according to a couple different answers I've found (Example #1, Example #2).  I can't figure out what I'm doing differently to cause it not to work in my case.

Outcomes