How to check if the BOM Structure is Inseparable and change it to normal?

How to check if the BOM Structure is Inseparable and change it to normal?

jake_egley
Advocate Advocate
387 Views
5 Replies
Message 1 of 6

How to check if the BOM Structure is Inseparable and change it to normal?

jake_egley
Advocate
Advocate

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

 

 

jake_egley_0-1737151300793.png

 

Jake Egley
Inventor 2022
0 Likes
Accepted solutions (1)
388 Views
5 Replies
Replies (5)
Message 2 of 6

Andrii_Humeniuk
Advisor
Advisor

Hi @jake_egley . I recommend in this case to use the AllReferencedDocuments method to get all documents included in the main assembly. Example below:

Dim oAsmDoc As AssemblyDocument
Dim oAsmCompDef As AssemblyComponentDefinition
Dim oRefDoc As Document
Set oAsmDoc = ThisApplication.ActiveDocument
Set oBOM = oAsmDoc.ComponentDefinition.BOM
Set oAsmCompDef = oAsmDoc.ComponentDefinition

'Change Bom structure to Normal for all that are inseparable

For Each oRefDoc In oAsmDoc.AllReferencedDocuments
	With oRefDoc.ComponentDefinition
	    If .BOMStructure = 51974 Then .BOMStructure = 51970
	End With
Next

Also, this way of obtaining documents is more appropriate for creating dxf files. 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 6

bradeneuropeArthur
Mentor
Mentor
Accepted solution
Public Sub ChangeBomStructure()
Dim A As AssemblyDocument
Dim ARD As Document
Set A = ThisApplication.ActiveDocument

For Each ARD In A.AllReferencedDocuments
If ARD.DocumentType = kAssemblyDocumentObject Or kPartDocumentObject Then

        If ARD.ComponentDefinition.BOMStructure = Inventor.BOMStructureEnum.kInseparableBOMStructure Then
        ARD.ComponentDefinition.BOMStructure = Inventor.BOMStructureEnum.kNormalBOMStructure
        End If
 End If
Next ARD
End Sub

Little modified/adjustments

Removed unnecessary declarations

More understandanble BOM declarations and check.

 

If you are ok with that still the solution is provided by @Andrii_Humeniuk . 

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 4 of 6

jake_egley
Advocate
Advocate

@bradeneuropeArthur Thanks brother that works. @Andrii_Humeniuk Appreciate it. I will say I tried using the all reference docs method for exporting dxf's and filling out my form but it is both slow and could not correctly get the part quantities due to the fact that it opens every document the amount of times its in the assembly or subassembly. For example it would open a piece of hardware 10 times because that piece of hardware was in 10 sub assemblies. I found the parts only bom method for iterating thru an assembly is faster and doesn't have that problem.

Jake Egley
Inventor 2022
Message 5 of 6

bradeneuropeArthur
Mentor
Mentor

Do you need support on that?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 6 of 6

jake_egley
Advocate
Advocate

I am support. Ha, no im good man, I finished the code and implemented it, I'm just working out the special cases now as they come up

Jake Egley
Inventor 2022
0 Likes