- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Unable to export the current BOM config
Hello,
I need to export a BOM to Excel, using a BOM XML template, but without modifying the BOM current structure.
So I use :
- save current BOM config in "BOM Tempo.xml"
- load existing BOM config
- ....
- load "BOM Tempo.xml"
The problem is the saved file "BOM Tempo.xml" does not match the current BOM config, it is always the same.
The code I use :
Sub test()
Set oAss = ThisApplication.ActiveDocument
Set oBOM = oAss.ComponentDefinition.BOM
'Define file name to export current BOM config
BOM_tempo = Environ("temp") & "\BOM_tempo.xml"
'if existing file, delete it
On Error Resume Next
Kill BOM_tempo
On Error GoTo 0
'Export active BOM config, in order to restore it
Call oBOM.ExportBOMCustomization(BOM_tempo)
'Load the custom BOM config file
oBOM.ImportBOMCustomization ("c:\temp\custom BOM.xml")
'...some code...
'Restore the original BOM config file
Call oBOM.ImportBOMCustomization(BOM_tempo)
End Sub
Normally I should have the same BOM config that I had at the beginning...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi,
You are loading a different file:
'Define file name to export current BOM config
BOM_tempo = Environ("temp") & "\BOM_tempo.xml"
'if existing file, delete it
On Error Resume Next
Kill BOM_tempo
On Error GoTo 0
'Export active BOM config, in order to restore it
Call oBOM.ExportBOMCustomization(BOM_tempo)
'Load the custom BOM config file
oBOM.ImportBOMCustomization ("c:\temp\custom BOM.xml")
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It is the right way :
- Define the name for CURRENT config --> BOM_tempo.xml
- Save current config in BOM_tempo.xml
- Load CUSTOM config --> custom BOM.xml
- ...some code...
- Restore the ORIGINAL config --> BOM_tempo.xml
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
'Define file name to export current BOM config
BOM_tempo = "c:\temp\custom BOM.xml"
'if existing file, delete it
On Error Resume Next
Kill BOM_tempo
On Error GoTo 0
'Export active BOM config, in order to restore it
Call oBOM.ExportBOMCustomization(BOM_tempo)
'Load the custom BOM config file
oBOM.ImportBOMCustomization ("c:\temp\custom BOM.xml")
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The following:
Public Sub bomexp()
Dim a As Application
Set a = ThisApplication
Dim b As AssemblyDocument
Set b = a.ActiveDocument
Dim c As BOM
Set c = b.ComponentDefinition.BOM
c.ExportBOMCustomization ("D:\BomTemporare.xml")
b.Save
c.ImportBOMCustomization ("D:\BomCustom.xml")
b.Save
c.ImportBOMCustomization ("D:\BomTemporare.xml")
b.Save
End SubEDIT.......................................................
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The edit works for me....
The save was the issue!
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sub test()
Set oAss = ThisApplication.ActiveDocument
Set oBOM = oAss.ComponentDefinition.BOM
'Define file name to export current BOM config
BOM_tempo = Environ("temp") & "\BOM_tempo.xml"
'if existing file, delete it
On Error Resume Next
Kill BOM_tempo
On Error GoTo 0
'Export active BOM config, in order to restore it
Call oBOM.ExportBOMCustomization(BOM_tempo)
oAss.save
'Load the custom BOM config file
oBOM.ImportBOMCustomization ("c:\temp\custom BOM.xml")
oAss.save
'...some code...
'Restore the original BOM config file
Call oBOM.ImportBOMCustomization(BOM_tempo)
oAss.save
End SubThis should work for your code......
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sorry that don't work...
The problem is really with the VBA command "ExportBOMCustomization".
If I stop the code just before the line "Call oBOM.ExportBOMCustomization(BOM_tempo)", export manually the BOM config from Inventor, don't execute the line and continue the macro it's ok.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You forgot to declare the assembly doc as assemblydocument as the bom as bom....
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The exports worked just fine for me when I did a test run to get the desired results that you want (export with a new BOM Style, and revert the config back to the original).
This leaves me thinking you have 1 of 2 issues:
1. Your 'some code' is undoing part of the process or somehow causing issues.
2. Your code to overwrite the BOM_tempo is not working properly and instead of storing the BOM config from the current file, it's just using a config version that had been saved in the past, which is the config you are seeing it restored to (instead of it's original config).
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization
iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread
Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects
Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help
Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here is the exact code I used to test :
Sub test()
Set oAss = ThisApplication.ActiveDocument
Set oBOM = oAss.ComponentDefinition.BOM
'Define file name to export current BOM config
BOM_tempo = Environ("temp") & "\BOM_tempo.xml"
'if existing file, delete it
On Error Resume Next
Kill BOM_tempo
On Error GoTo 0
'1-Export active BOM config, in order to restore it
Call oBOM.ExportBOMCustomization(BOM_tempo)
'2-Load the custom BOM config file
oBOM.ImportBOMCustomization ("c:\temp\custom BOM.xml")
'3-Restore the original BOM config file
Call oBOM.ImportBOMCustomization(BOM_tempo)
End Sub
Test procedure :
- Open an iam
- From Inventor, edit BOM and modify columns
- Close BOM
- Launch the program in debug mode
- STOP at 1
- Check BOM_tempo value and check date of the file BOM_tempo.xml --> it's ok
- Run and STOP at 2
- EXIT the program, go back to Inventor
- Open the BOM
- Load manually the file BOM_tempo.xml --> NOT ok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I found where is the bug:
- From Inventor, the BOM has 3 tabs : Model, Structured and Parts only.
- When you export manually, all the 3 tabs are exported
- When you export by VBA, only the Model tab is exported, and it is only that tab which is restored, on Model, Structured and Parts only.
To check it :
1)VB export :
- From Inventor, on an assembly, edit the BOM to have different configs on the 3 tabs
- Using the macro, export the BOM config and stop the program
- Manually, from Inventor, load the exported config : you obtain same columns in all the 3 tabs
2)Manual export :
- From Inventor, on an assembly, edit the BOM to have different configs on the 3 tabs
- Manually, export the BOM config to BOM_tempo.xml
- Manually, from Inventor, Edit and modify the BOM config
- Manually, import the BOM config from BOM_tempo.xml : you obtain the right config you saved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
By default, Model tab is exported. If you want to export Structured tab, need to enable and export the same. Similarly for Parts Only tab. So, there are 3 xml files to export and import. Below VBA code exports different excels for different tabs.
Public Sub BOMExport()
' Set a reference to the assembly document.
' This assumes an assembly document is active.
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
' Set a reference to the BOM
Dim oBOM As BOM
Set oBOM = oDoc.ComponentDefinition.BOM
' Set the structured view to 'all levels'
oBOM.StructuredViewFirstLevelOnly = False
' Make sure that the structured view is enabled.
oBOM.StructuredViewEnabled = True
' Set a reference to the "Structured" BOMView
Dim oStructuredBOMView As BOMView
Set oStructuredBOMView = oBOM.BOMViews.Item("Structured")
' Export the BOM view to an Excel file
oStructuredBOMView.Export "C:\temp\BOM-StructuredAllLevels.xls", kMicrosoftExcelFormat
' Make sure that the parts only view is enabled.
oBOM.PartsOnlyViewEnabled = True
' Set a reference to the "Parts Only" BOMView
Dim oPartsOnlyBOMView As BOMView
Set oPartsOnlyBOMView = oBOM.BOMViews.Item("Parts Only")
' Export the BOM view to an Excel file
oPartsOnlyBOMView.Export "C:\temp\BOM-PartsOnly.xls", kMicrosoftExcelFormat
End Sub
Please feel free to contact if there is any queries.
If solves problem, click on "Accept as solution" / give a "Kudo".
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network
