- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a macro that iterates through the parts only bom of an assembly and makes a dxf for each sheet metal part and gets the quantity of each part for a spreadsheet. Problem we have found is when an assembly contains a weldment it doesn't work because the weldment has a bom structure of Inseparable. I found code that can change the structure to "normal" which works, but if there is anything else in the assembly that has a bom structure such as purchased I don't want to change that normal. So I need code that can check but I'm having trouble getting a condition to work for checking. I also found that sometimes the bom structure is read-only and I can't change it. This is my code right now. Any help is appreciated.
Dim oAsmDoc As AssemblyDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Dim oOccurrence As ComponentOccurrence
Set oAsmDoc = ThisApplication.ActiveDocument
Set oBOM = oAsmDoc.ComponentDefinition.BOM
Set oAsmCompDef = oAsmDoc.ComponentDefinition
' Make sure that the parts only view is enabled.
oBOM.PartsOnlyViewEnabled = True
'Change Bom structure to Normal for all that are inseparable
For Each oOccurrence In oAsmCompDef.Occurrences
If oOccurrence.Definition.BOMStructure = 51974 Then '51974 is inseparable
oOccurrence.Definition.BOMStructure = 51970 'Normal Bom Structure
End If
Next
Inventor 2022
Solved! Go to Solution.