'Adapted from Inventor API Samples by Clint Brown @ClintCadline 'Originally posted on Cadline Community https://www.cadlinecommunity.co.uk/hc/en-us/articles/212849309 oDoc = ThisDoc.ModelDocument If oDoc.DocumentType = kPartDocumentObject Then MessageBox.Show("You need to be in an Assembly to Export a BOM", "Cadline: iLogic - BOM Publisher") Return End If oDoc = ThisApplication.ActiveDocument Dim oBOM As BOM oBOM = oDoc.ComponentDefinition.BOM '========================================================================================== 'You can change the output path by editing oPATH below oPATH = ("c:\temp\") 'If you change this, remember to keep a \ at the end '========================================================================================== 'STRUCTURED BoM =========================================================================== ' the structured view to 'all levels' oBOM.StructuredViewFirstLevelOnly = False ' Make sure that the structured view is enabled. oBOM.StructuredViewEnabled = True Dim oStructuredBOMView As BOMView oStructuredBOMView = oBOM.BOMViews.Item("Structured") ' Export the BOM view to an Excel file oStructuredBOMView.Export (oPATH + ThisDoc.FileName(False) + ".xls", kMicrosoftExcelFormat) '========================================================================================== 'PARTS ONLY BoM =========================================================================== '' Make sure that the parts only view is enabled. 'oBOM.PartsOnlyViewEnabled = True 'Dim oPartsOnlyBOMView As BOMView 'oPartsOnlyBOMView = oBOM.BOMViews.Item("Parts Only") '' Export the BOM view to an Excel file 'oPartsOnlyBOMView.Export (oPATH + "BOM-PartsOnly.xls", kMicrosoftExcelFormat) '========================================================================================== i = MessageBox.Show("Preview the BOM?", "Cadline: iLogic - BOM Publisher",MessageBoxButtons.YesNo) If i = vbYes Then : launchviewer = 1 : Else : launchviewer = 0 : End If If launchviewer = 1 Then ThisDoc.Launch(oPATH + ThisDoc.FileName(False) + ".xls")