BOM.ExportBOMCustomization - Suspected Bug - Code Included

BOM.ExportBOMCustomization - Suspected Bug - Code Included

LukeDavenport
Collaborator Collaborator
1,081 Views
5 Replies
Message 1 of 6

BOM.ExportBOMCustomization - Suspected Bug - Code Included

LukeDavenport
Collaborator
Collaborator

 

Hi,

The above method does not produce an XML with the correct BOM columns for all three BOM views. Please try the following for simple reproduction of this error.

 

1) Create a new assembly.

2) Alter the BOM columns for the 'Structured' view (for instance, add a non-standard property such as 'Filename' as a column).

3) Run the below iLogic rule.

4) Check the exported XML file called 'TestExport.xml' in your temp directory.

5) Note that the column format does not represent your saved format (see screenshot below)

6) Note also that a manually exported BOM customization file (using UI) WILL be correctly formatted. See screenshot below.

 

Autodesk please reproduce error using my code and assist if possible.

Many thanks,

Luke

 

BOM Error.png

 

 

 

 

 

 

 

 

 

 

 

 

 

SyntaxEditor Code Snippet

   Dim oDoc As AssemblyDocument = ThisApplication.ActiveEditDocument
        Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
        Dim oMgr As RepresentationsManager = oDef.RepresentationsManager

        ThisApplication.SilentOperation = True
        Dim InitialLOD As String = oMgr.ActiveLevelOfDetailRepresentation.Name
        ' Check current LOD - if it is not 'Master' then the structured BOM can't be accessed...
        If Not InitialLOD = "Master" Then
            ' Switch to master LOD
            oMgr.LevelOfDetailRepresentations("Master").Activate(True)
        End If
        ThisApplication.SilentOperation = False

        'set  a reference to the BOM
        Dim oBOM As BOM = oDoc.ComponentDefinition.BOM

        ' Export BOM customization
        Dim TempXMLName As String = System.IO.Path.GetTempPath & "TestExport" & ".xml"
        If System.IO.File.Exists(TempXMLName) Then
            System.IO.File.Delete(TempXMLName)
        End If

        ' Get the structured BOM view 
        Dim oBOMView As BOMView = oBOM.BOMViews.Item(2)

        oDoc.Rebuild()

        oBOM.ExportBOMCustomization(TempXMLName) 

 

 

0 Likes
1,082 Views
5 Replies
Replies (5)
Message 2 of 6

LukeDavenport
Collaborator
Collaborator

 

Hi,

This issue can be very easily reproduced on anyones machine using the iLogic code I've pasted below. Can someone from Autodesk support take a few minutes to follow my 6 bullet points above?

Many thanks,

Luke

Message 3 of 6

Josh_Hunt
Advocate
Advocate

@ChrisMitchell01 or @dan_szymanski 

 

FYI: AssemblyComponentDefinition.BOM.ExportBOMCustomization(XmlPath) is still a broken in Inventor 2020. It is an untrustworthy API. I hope this is a simple fix because the button works as expected.

 

The API is so broken that it hides the ITEM property visibility so it cannot be manually added back... unless you import a correct XML.

 

Josh_Hunt_1-1625859060502.png

 

This simple iLogic rule will export a very different XML than the BOM 'Export...' button. Examples attached from a new/unedited IAM.

Dim IAMdoc As AssemblyDocument = ThisDoc.Document
Dim path As String = "C:\TEMP\New IAM BOM via Code iLogic.xml"
IAMdoc.ComponentDefinition.BOM.ExportBOMCustomization(path)

 

Josh Hunt
0 Likes
Message 4 of 6

Josh_Hunt
Advocate
Advocate

See the attached XMLs. Appears this was resolved in Inventor 2022.

Josh Hunt
0 Likes
Message 5 of 6

Inv.Connect
Explorer
Explorer

Hi Josh,

 

This was fixed in Inventor 2021. Have you plan to upgrade to Inventor 2021 or 2022?

0 Likes
Message 6 of 6

Josh_Hunt
Advocate
Advocate

@Inv.Connect I tested Inventor 2021.3.1 and got the same buggy export (attached).

 

My primary client is on Inventor 2020 and upgraded recently (early 2020).

 

Also, I was hoping to code something that worked for many clients on many versions.

Josh Hunt
0 Likes