Example of exporting settings:
Dim oDoc As Document = ThisDoc.Document
If oDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
Dim oADoc As AssemblyDocument = oDoc
Dim oBOM As BOM = oADoc.ComponentDefinition.BOM
Dim sPathFile As String = "D:\BOM.xml"
oBOM.ExportBOMCustomization(sPathFile)
Example of importing settings:
Dim oDoc As Document = ThisDoc.Document
If oDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
Dim oADoc As AssemblyDocument = oDoc
Dim oBOM As BOM = oADoc.ComponentDefinition.BOM
Dim sPathFile As String = "D:\BOM.xml"
oBOM.ImportBOMCustomization(sPathFile)
Line 5 is the path to the .xml file.
If you need to update the BOM table in sub-assemblies, you can use the For each statement, here is an example:
Dim oDoc As Document = ThisDoc.Document
If oDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
Dim oADoc As AssemblyDocument = oDoc
Dim sPathFile As String = "D:\BOM.xml"
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
If oRefDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Continue For
If Not oRefDoc.IsModifiable Then Continue For
Dim oBOM As BOM = oRefDoc.ComponentDefinition.BOM
Try : oBOM.ImportBOMCustomization(sPathFile) : Catch : End Try
Next