Inventor 2022, BOM Export component definition Issues
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone,
A couple of years ago we wrote an iLogic code to export the BOM from the assembly model to a template Excel.
Earlier this year we updated to 2022 and we've recently been using model states, which have been giving error with the export code.
If we have a "normal" assembly the code works fine. Even if, within that assembly, a subassembly is used with a model state.
If the main assembly has different model states however, the code fails.
It specifically fails in the Public sub, with component definitions of the BOMRow items. (Line 15)
If we change Line 101 with the addition .FactoryDocument the code accepts the component definitions but gives an error at PropertySets. (Line 18)
And the code doesn't work anymore for assemblies without model states. (also error on line 18)
I hope my issue is clear, and apologies for the long code:
Call QueryBOMRowProperties(oBOMView.BOMRows, sNewBOM, iCurrRow)
Public Sub QueryBOMRowProperties(oBOMRows As BOMRowsEnumerator, JobSpreadsheetName As String, iCurrRow As Integer)
' Iterate through the contents of the BOM Rows
Static CurrentRow As Integer = iCurrRow
Dim i As Long
For i = 1 To oBOMRows.Count
' Get current row
Dim oRow As BOMRow
oRow = oBOMRows.Item(i)
Dim oCompDef As ComponentDefinition
oCompDef = oRow.ComponentDefinitions.Item(1)
Dim oPropSets As PropertySets
oPropSets = oCompDef.Document.PropertySets
' File property shortcuts
oDesignTrackingPropertySet = oPropSets.Item("Design Tracking Properties") 'Project tab shortcut
oInventorSummaryPropertySet = oPropSets.Item("Inventor Summary Information") 'Summary tab shortcut
oCustomPropertySet = oPropSets.Item("Inventor User Defined Properties") 'Custom tab shortcut
' Get the file properties that are required
oItemNumberProperty = oRow.ItemNumber
oPartNumProperty = oDesignTrackingPropertySet.Item("Part Number")
oDescripProperty = oDesignTrackingPropertySet.Item("Description")
oTitleProperty = oInventorSummaryPropertySet.Item("Title")
' Recursively iterate child rows if present
If Not oRow.ChildRows Is Nothing Then
Call QueryBOMRowProperties(oRow.ChildRows, JobSpreadsheetName, CurrentRow)
Else
End If
Next i
End Sub
I've been trying to get the code to work but it has been driving me crazy.
Any advice or referrals are greatly appreciated.