Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Unable to export the current BOM config

TONELLAL
Collaborator

Unable to export the current BOM config

TONELLAL
Collaborator
Collaborator

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...

0 Likes
Reply
1,830 Views
33 Replies
Replies (33)

TONELLAL
Collaborator
Collaborator

I think you don't understand what I need : I want to export the BOM config  to an XML file, not the BOM.to an Excel file.

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@TONELLAL,

 

Hoping that below posts would help to solve

 

https://forums.autodesk.com/t5/inventor-customization/ilogic-bom-export-column-order/td-p/5729339

 

https://forums.autodesk.com/t5/inventor-customization/thisbom-export-column-order-problem/m-p/490203...

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

TONELLAL
Collaborator
Collaborator

These posts are totally different from my problem.

I don't need to export the BOM content to an xls file, I need to export the BOM config to an XML file.

I explained above the exact procedure, with the VBA code, to see where is the problem.

Please, use the code sent and test with the procedure, you will see where is the problem.

If it is not clear, I can send you a Screencast.

0 Likes

bradeneuropeArthur
Mentor
Mentor

Hi,

 

That is also why I was away, didn't get what the XLS file had to do with this.

But still my earlier post works for me at least.

 

try this again and we have a point where we have ended correctly.

 

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 Sub

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 !

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@TONELLAL,

 

 

Steps to reproduce the issue through VBA code.

 

  1. Modify or add some columns in Model Data, Structured and Parts Only tabs.
  2. Export the BOM columns through VBA code (given in the previous code).
  3. On loading exported xml either through manual or VBA code, All 3 tabs contains same columns of "Model data" tab.

Am I missing anything? if it is there, please mention the same.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

bradeneuropeArthur
Mentor
Mentor
Hi,

Am I correct that you need:
1 Export the current BOM settings to XML
2 import BOM settings from your directory.
3 do some coding
4 reset to the in 1 Exported Bom

this is what my code does.
Or do you need more?

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 !

0 Likes

TONELLAL
Collaborator
Collaborator

@bradeneuropeArthur :

this is exactly what I need, you can even delete point 3 to simplify.

 

@Anonymous.shekar :

Before the export, BOM columns are different in Model Data, Structured and Parts Only.

If I load exported XML manually, it's ok, I get back the original config.

If I load XML by VBA, Model Data, Structured and Parts Only contain the same columns, corresponding at Model Data.

0 Likes

bradeneuropeArthur
Mentor
Mentor

@TONELLAL

 

where is my last posted code going wrong?

I have tested and It worked fine!

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 !

0 Likes

TONELLAL
Collaborator
Collaborator

It work fine only for Data Model.

Try this :

-modify the BOM structure in Model, Structured and Parts only, to have 3 different configurations

-launch your code

-check the BOM : Model, Structured and Parts only tabs are identical.

0 Likes

MechMachineMan
Advisor
Advisor

Good find @TONELLAL. This is indeed a bug.

 

@chandra.shekar.g, you might want to pass this one on to engineering.

 

I have done tests and confirmed that the issue is with the ExportCustomization API command.

 

You can do tests yourself by manually exporting the xml config and viewing the settings and comparing it to one exported with the API.

 

In my test, I hid all rows but 2 for each of the tabs (Model had Part Number & Thumbnails only, Structured had Part Number & File Path only, Parts Only only had the Part Number).

 

The full VB workflow did in fact apply P/N & Thumbnails to all of the tabs upon reloading, so I investigated the xml files.

 

You can clearly see that it's not properly setting the xml for what they correspond to, so it's a confirmed export issues.

 

(in my case, I searched up the Property that was ORIGINALLY inconsistent between the 3 tabs (Thumbnails) and found the 

<property name="Visible">false</property>

line immediately below it. 

 

Manual export showed behavior that was coincident with what I would expect based on the BOM layout. VBA Export did NOT show behavior consistent to what was expected.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
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

chandra.shekar.g
Autodesk Support
Autodesk Support

@TONELLAL,

 

 

If screencast is there, it would be easy to communicate with engineering team.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

TONELLAL
Collaborator
Collaborator

I don't think video can be more than above explanations.

You only need :

-export BOM config using API  --> you obtain XML1

-export BOM config manually --> you obtain XML2

-compare XML1 and XML2

-That's all !

MechMachineMan
Advisor
Advisor

@chandra.shekar.g@MjDeck

 

Attached are 2 xml files of BOM configurations for an iam file.

 

"testing manual export.xml" was exported through the UI.

"BOM_tempo.xlm" was exported through the API.

 

Between their exports, no changes were made to the BOMs, nor were any customization files loaded.

 

If you run the text of both files through diffchecker.com, it shows 16 differences between the 2 files while should be identical. The manual export works properly, the automated one does not.

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
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
0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@TONELLAL, @MechMachineMan,

 

Finally, a change request is created with engineering team.

 

INVGEN - 13594 - Exporting and importing assembly BOM config via VBA code is incorrect

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network