iLogic / VBA to change BOM structure of all visible/invisible parts

iLogic / VBA to change BOM structure of all visible/invisible parts

nick2C5YB
Contributor Contributor
870 Views
2 Replies
Message 1 of 3

iLogic / VBA to change BOM structure of all visible/invisible parts

nick2C5YB
Contributor
Contributor

Dear All,

 

Currently im working with assemblys with a lot of different configurations (excel driven). The visibility of specific pats are controlled bye true/false user parameters. I'm looking for a rule/code to change the BOM Structure of all invisible parts to Reference and the structure of all visible parts to Default.  

 

I've achieved to change the BOM structure for each part with a seperate line of code:

 

If OZP = 1 Then
 Component.Visible("B200001:6") = True
 Component.InventorComponent("B200001:6").BOMStructure = BOMStructureEnum.kDefaultBOMStructure
 Else
 Component.Visible("B200001:6") = False
 Component.InventorComponent("B200001:6").BOMStructure = BOMStructureEnum.kReferenceBOMStructure
End If

 

But I would like to apply a global rule that read the whole document and change the BOM structure of each invisible/visible part in the assembly.

 

I know LoD can achieve this easy, but I just want to avoid using them. They give me to much trouble in this project.

 

Does somebody have any ideas suggestions??

 

Many thanks up front

0 Likes
Accepted solutions (1)
871 Views
2 Replies
Replies (2)
Message 2 of 3

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

 

oCompDef = ThisDoc.Document.ComponentDefinition

For Each oOcc As ComponentOccurrence In oCompDef.Occurrences
	If oOcc.Visible = True Then
		oOcc.BOMStructure = BOMStructureEnum.kDefaultBOMStructure
	Else
		oOcc.BOMStructure = BOMStructureEnum.kReferenceBOMStructure
	End If
Next

 Hi, try this code snippet maybe I can help you, regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 3

nick2C5YB
Contributor
Contributor

Exactly what I was looking for! Awesome, sets all the invisible parts to reference. So part lists & Mass calculations are always right. 

 

Thanks you very much sir!

0 Likes