Using ILogic to to control BOM structure in assembly

Using ILogic to to control BOM structure in assembly

Anonymous
Not applicable
5,628 Views
20 Replies
Message 1 of 21

Using ILogic to to control BOM structure in assembly

Anonymous
Not applicable

Hello.

 

I need help to control the BOM structure in the assembly with ILogic to make parts in the assembly Phantom and Normal by an If rule. 

someone said this would work but i cannot figure out if it's possible or even if it's the right rule

 

'get the reference to the component by its name
Dim oOcc As ComponentOccurrence = Component.InventorComponent("INNER_STIFFENING_RING​​_1")
' set BOM structure to Phantom
oOcc.Definition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure
'oOcc.Definition.BOMStructure = BOMStructureEnum.kNormalBOMStructure 'oOcc.Definition.BOMStructure = BOMStructureEnum.kPurchasedBOMStructure 'oOcc.Definition.BOMStructure = BOMStructureEnum.kInseparableBOMStructure

 Hope you can help.

with best regards Mikael Nanke.

0 Likes
5,629 Views
20 Replies
Replies (20)
Message 2 of 21

Mark.Lancaster
Consultant
Consultant

@Anonymous

 

I could be wrong in regards to iLogic..  But in an assembly the component BOM structure can only be changed to "REFERENCE" or its "default" configuration (Tools/Document Settings/BOM tab) at the assembly level.  @Curtis_Waguespack is that also correct in iLogic?

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

0 Likes
Message 3 of 21

Anonymous
Not applicable

Hey mark.

 

No, as shown in the attached picture, A part in the assembly can be either Normal, Inseparable, Purchased, Phantom and Reference.

 

I was hoping to use ILogic to change the that parameter in the bill of materials so my part list will exclude certan parts.

 

 

0 Likes
Message 4 of 21

Mark.Lancaster
Consultant
Consultant

@Anonymous

 

OK you are changing it that way..  But when you do so you are impacting all the assembly's this component belongs to.  Meaning you are changing the BOM structure under the component's document settings/BOM.  It is not changing it for that given assembly.   You are making the modification at the part level.  Is that what you are trying to accomplish?

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

0 Likes
Message 5 of 21

Anonymous
Not applicable

I'm having a little hard time on explaning what the specific objectiv/solution to the problem is.
But as shown in the picture, I want the Bill of materials in the top assembly to change 2 parts BOM structure so they are Phantom indead of Normal status.
I'm using a form which switch a part out with another and i need to remove the 1st one in the first setting and remove the other in the other setting.

 

 

As show in the new picture, i'm using the form and the 2 stages it can be in.

0 Likes
Message 6 of 21

Mark.Lancaster
Consultant
Consultant

If you change them to phantom then those parts are phantom (BOM structure) in every assembly where these components are used.  Is that OK?  I don't know is these components are used in other assemblies or just this one.

 

If not..  Then like I said its not possible to change the BOM structure of a given part in a given assembly to Phantom..  You can only change it to "REFERENCE" or back to its default BOM structure.

 

When you are changing the structure in the Assembly BOM view, you are modifying the actual part (which then impacts all the assemblies this component belongs to).

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

0 Likes
Message 7 of 21

Anonymous
Not applicable
No it's not a problem that the parts are Phantom in all assemblies, because this is the only place it's used.
0 Likes
Message 8 of 21

Mark.Lancaster
Consultant
Consultant

@Anonymous

 

@Curtis_Waguespack may have an updated code but you can see his code here in this posting that should help you out.

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

0 Likes
Message 9 of 21

Anonymous
Not applicable
I have seen somthing similar make by Curtis, but this code is very confusing and i dont want to select a part and cant figure out what the numbers are for. I'm looking for a simple code that can phantom 2 parts in my assembly and change them back to normal again with my ILogic rule
0 Likes
Message 10 of 21

Curtis_Waguespack
Consultant
Consultant

Hi mikael_nanke,

 

One of these should work.

 

 

If you know that your components exact name including instance number you can use this:

 

' set a reference to the assembly component definintion
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
	If oOccurrence.Name = "INNER_STIFFENING_RING​​​_1:1" Then
		'set BOM Structure
		oOccurrence.Definition.BOMStructure = 51971 'Phantom 
	End If
Next

 

 

If not you can use "Contains" as in this example:

 

 

' set a reference to the assembly component definintion
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
	If oOccurrence.Name.Contains("INNER_STIFFENING_RING​​​_1") = True Then
		'set BOM Structure
		oOccurrence.Definition.BOMStructure = 51971 'Phantom 
	End If
Next

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 11 of 21

Anonymous
Not applicable
Hello Curtis.
I'm almost honored, that you are responding to my thread.

I'm right now testing your code thank you very much.
But can you tell me what the 51971 means?
0 Likes
Message 12 of 21

Anonymous
Not applicable

As you can see in the picture i have uploaded. my parts are in a subassembly. is that why i'm having problems with your code?

 

best regards Mikael Hansen

0 Likes
Message 13 of 21

Anonymous
Not applicable
And here is the total code for the switching out the parts and making the non used parts phantom. hope you can see what i'm missing.

http://pastebin.com/HkbkT8SJ
0 Likes
Message 14 of 21

Anonymous
Not applicable
Here are the corrected Version of the code. hope it makes sense

http://pastebin.com/rvCWSfv5
0 Likes
Message 15 of 21

Curtis_Waguespack
Consultant
Consultant

@Anonymous wrote:

But can you tell me what the 51971 means?

 

Hi mikael_nanke,

 

That number is the Enumerator value. My example called the value directly, whereas in your first example you used this: BOMStructureEnum.kPhantomBOMStructure

 

Yours was more proper, but both will work.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

 

BOMStructureEnum Enumerator

Description

BOM structure types.

Methods

Name Value Description
kDefaultBOMStructure 51969 The default structure type.
kInseparableBOMStructure 51974 The inseparable structure type.
kNormalBOMStructure 51970 The normal structure type.
kPhantomBOMStructure 51971 The phantom structure type.
kPurchasedBOMStructure 51973 The purchased structure type.
kReferenceBOMStructure 51972 The reference structure type.
kVariesBOMStructure 51975 The structure type varies amongst references.

EESignature

Message 16 of 21

Curtis_Waguespack
Consultant
Consultant

Hi mikael_nanke,

 

I think you're correct, in that the current code is not looking into the sub assembly.

See this example, as I think it will be very close to what you're wanting to do.

 

http://forums.autodesk.com/t5/inventor-customization/change-bom-structure-to-reference-at-parts-in-a...

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 17 of 21

Anonymous
Not applicable
Thank you for replying Curtis.

I have been looking through the code you send me and it looks promising, I will start testing it today

But there is a part in the code i cant quite understand. why is

ThisApplication.Documents.Open(docFile.FullFileName, False)

and not true?

0 Likes
Message 18 of 21

Curtis_Waguespack
Consultant
Consultant

Hi mikael_nanke 

 

False opens the file invisibly, true will open normally.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

 

Documents.Open Method

Parent Object: Documents

Description

Method that opens the specified Inventor document.

Syntax

Documents.Open( FullDocumentName As String, [OpenVisible] As Boolean ) As Document

Parameters

Name Description
FullDocumentName Input String that specifies the full document name of the document to open. If only the FullFileName is specified for part and assembly documents, the master document within the file is opened.
OpenVisible Optional input Boolean that specifies whether to open the document as visible.

EESignature

0 Likes
Message 19 of 21

Anonymous
Not applicable

Hi again Curtis.

 

I have now returned from my holiday and fiddeled with the code you send me.
But i must admit i cannot solve this by my self and i need your help again.

 

SyntaxEditor Code Snippet

If Vogn_Model="Vejle"Then
ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Vejle").Activate
iLogicVb.UpdateWhenDone=True

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Name.Contains("3699-2031.10") = True Then
        oOccurrence.Definition.BOMStructure = 51971 'Phantom 
    End If
Next 

For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Name.Contains("3699-2031.11") = True Then
        oOccurrence.Definition.BOMStructure = 51971 'Phantom 
    End If
Next 

For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Name.Contains("3699-2031.10 Vejle") = True Then
        oOccurrence.Definition.BOMStructure = 51970 'Normal 
    End If
Next 

For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Name.Contains("3699-2031.11 Vejle") = True Then
        oOccurrence.Definition.BOMStructure = 51970 'Normal 
    End If
    
Next 


Else If Vogn_Model="Standard"Then
ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Standard").Activate
iLogicVb.UpdateWhenDone=True

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Name.Contains("3699-2031.10") = True Then
        oOccurrence.Definition.BOMStructure = 51970 'Normal 
    End If
Next 

For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Name.Contains("3699-2031.11") = True Then
        oOccurrence.Definition.BOMStructure = 51970 'Normal 
    End If
Next 

For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Name.Contains("3699-2031.10 Vejle") = True Then
        oOccurrence.Definition.BOMStructure = 51971 'Phantom 
    End If
Next 

For Each oOccurrence In oAsmCompDef.Occurrences
    If oOccurrence.Name.Contains("3699-2031.11 Vejle") = True Then
        oOccurrence.Definition.BOMStructure = 51971 'Phantom 
    End If
Next 

End If

InventorVb.DocumentUpdate()

 

 

As you can see in the code i have posted, it looks like the last one i used, and everytime i try to input parts of the code you send me, i come up with errors or no change at all.

I would be much appreciated if you can solve this puzzle.

 

Wtih be regards, Mikael Nanke

0 Likes
Message 20 of 21

llorden4
Collaborator
Collaborator

*deleted*

Autodesk Inventor Certified Professional
0 Likes