changing BOMStructure via iLogic within one line

changing BOMStructure via iLogic within one line

Kay_Rethmeier
Advocate Advocate
391 Views
2 Replies
Message 1 of 3

changing BOMStructure via iLogic within one line

Kay_Rethmeier
Advocate
Advocate

Hi,

 

I'm able to change the BOM Structure within a single line from default to reference. But the other possibilities doesn't work. Any ideas to have a change within a single line?

 

SyntaxEditor Code Snippet, these two are working!!!!

Component.InventorComponent("MyPart").BOMStructure = BOMStructureEnum.kReferenceBOMStructure 
Component.InventorComponent("MyPart").BOMStructure = BOMStructureEnum.kDefaultBOMStructure

  But these aren't working:

SyntaxEditor Code Snippet

Component.InventorComponent("MyPart").BOMStructure = BOMStructureEnum.kPhantomBOMStructure
Component.InventorComponent("MyPart").BOMStructure = BOMStructureEnum.kNormalBOMStructure

 Thanks in advance!

Kay

Cheers
Kay (Principal CAD-Consultant)
0 Likes
392 Views
2 Replies
Replies (2)
Message 2 of 3

Kay_Rethmeier
Advocate
Advocate

Hi agian,

 

OK, some next informations:

my two lines at the beginning are switching the compontents inside the assembly (manually done within the browser). 

Component.InventorComponent("MyPart").BOMStructure = BOMStructureEnum.kReferenceBOMStructure 
Component.InventorComponent("MyPart").BOMStructure = BOMStructureEnum.kDefaultBOMStructure

It isn't possible to use the other options (kInseparableBOMStructure, kPurchasedBOMStructure, kPhantomBOMStructure, kNormalBOMStructure) here. So far so good.

 

But maybe somone has an idea to shorten the rule from this:

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOccurrence As ComponentOccurrence

For Each oOccurrence In oAsmCompDef.Occurrences
	If oOccurrence.Name = "MyPart" Then
		oOccurrence.Definition.BOMStructure = kInseparableBOMStructure
	End If
Next

 to a single line. It will be perfect if a coulpe of BOM manipulations have to be done.

Ciao

Kay

Cheers
Kay (Principal CAD-Consultant)
0 Likes
Message 3 of 3

HermJan.Otterman
Advisor
Advisor

Hello Kay,

 

maube this will help:

use sub's, the first will need to be called "Main"

 

SyntaxEditor Code Snippet

Sub main
	
	'one line that call an other sub
	changeToReference("MyPart")
	changeToReference("MysecondPart")
	'etc
	
End Sub
	
	
	
	
Sub changeToReference(ByVal occurrenceName As String)
		
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim oOccurrence As ComponentOccurrence

For Each oOccurrence In oAsmCompDef.Occurrences
	If oOccurrence.Name = occurrenceName Then
		oOccurrence.BOMStructure = kReferenceBOMStructure
	End If
Next
		
End Sub

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan