Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding
Community
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API Support for Export BOM with Template

API Support for Export BOM with Template

Hi,

 

Since Inventor R2022.1 it's possible to export a BOM with options (Inventor 2023 Help | Assembly Enhancements | Autodesk), like using an Excel template. But the API does not support these options (Inventor 2023 Help | BOMView.Export Method | Autodesk).

Please make these options available in the API as well.

2 Comments
JBerns
Advisor

@theo.bot

 

I hope I understand what you mean by API and BOM, but I have been exporting the BOM since Inventor 2019.

 

I offer this code. Please let us know if it is helpful.

 

' ----------------------------------------------------------------------------------	
' Export to XLSX

' Create a new NameValueMap object
Dim oOptionsBOM As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap

' Specify an existing Excel template file to use for formatting colors, fonts, etc
oOptionsBOM.Value("Template") = "\\YourServer\YourFolder\YourBomTemplate.xlsx"

' Verify existence of template file
If Not System.IO.File.Exists(oOptionsBOM.Value("Template")) Then
	MessageBox.Show("No BOM Template found:" & vbLf & vbLf & oOptionsBOM.Value("Template") & vbLf & vbLf & "Contact the CAD Administrator.", _
	"WARNING", _
	MessageBoxButtons.OK, MessageBoxIcon.Warning)
	Exit Sub
End If

' Specify the columns to export         
oOptionsBOM.Value("ExportedColumns") = "BOM;QTY;STOCK NUMBER;DESCRIPTION"

' Specify the start cell on the destination workbook
oOptionsBOM.Value("StartingCell") = "A1"

' Specify the XLSX destination tab (sheet) name
oOptionsBOM.Value("TableName") = "YourSheetName"

' Choose to include the parts list title row
If oPartsList.ShowTitle = True Then
	oOptionsBOM.Value("IncludeTitle") = True
Else
	oOptionsBOM.Value("IncludeTitle") = False
End If

' Choose to autofit the column width in the xlsx file
oOptionsBOM.Value("AutoFitColumnWidth") = True

' Export the PartsList to Excel with options
oPartsList.Export(oExportFileName, PartsListFileFormatEnum.kMicrosoftExcel, oOptionsBOM)

 

Regards,

Jerry

theo.bot
Collaborator

@JBerns 

 

Your right about your export methode, but that’s a rule in a drawing exporting the partslist. 

I would like to export the bill of material from the assembly file using a template using the api. In the user interface it’s already possible to do.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea  

Autodesk Design & Make Report