Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change BOM Structure of my Current Assembly

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Josh_Hudson97
475 Views, 11 Replies

Change BOM Structure of my Current Assembly

Hi,

 

Is it possible to change the BoM Structure of the assembly you are in using iLogic based in given conditions?

 

I know I can change components with the assembly (as seen here on this post). But I want to change the structure of the top level assembly I am working in.

If I've helped you out drop the post a like, if I've given you a solution mark as solved. It's us, 'The community' that makes this place work 😄
Labels (4)
11 REPLIES 11
Message 2 of 12
A.Acheson
in reply to: Josh_Hudson97

Hi @Josh_Hudson97 

The BOM structure Enum is changed from the component definition of either a part or assembly file. 

So it will follow a similar setup to the occurrence. See help page here for assemblyComponentDefinition

Syntax

AssemblyComponentDefinition.BOMStructure() As BOMStructureEnum

 

Keep in mind this will change the structure for every other occurrence of this Assembly. The structure is completely tied to the document.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 12
Josh_Hudson97
in reply to: A.Acheson

HI @A.Acheson,

 

Thank you! I'll have a look and see how I get on.

 

I'm hoping the fact it is tied to a document will be ok as I'm doing this with a factory asset so each different configuration creates a new version of the file. But this will need me to do some testing so I'll get back with how I get on 🫰

If I've helped you out drop the post a like, if I've given you a solution mark as solved. It's us, 'The community' that makes this place work 😄
Message 4 of 12

Hi @A.Acheson  just an update on this one for anyone looking back. Below is my rule (Very simple in the end).

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

If POST_CENTRES = 2970 Then
	iProperties.Value("Project", "Part Number") = "Set Part Number"
	oAsmCompDef.BOMStructure = 51970 'Normal
ElseIf POST_CENTRES = 3570 Then
	iProperties.Value("Project", "Part Number") = "Set Part Number"
	oAsmCompDef.BOMStructure = 51970 'Normal
ElseIf POST_CENTRES = 4170 Then
	iProperties.Value("Project", "Part Number") = "Set Part Number"
	oAsmCompDef.BOMStructure = 51970 'Normal
Else
	iProperties.Value("Project", "Part Number") = "SPECIAL SALES KIT REQUIRED"
	oAsmCompDef.BOMStructure = 51971 'Phantom
End If

InventorVb.DocumentUpdate()

iLogicVb.UpdateWhenDone = True

 

The issue I now have is this doesn't update the BoM structure when using in a factory layout. It will work if I open the part and run it manually but doesn't happen on its own, anyone got any ideas? 

 

Edit:

 

I know the rule is running in the factory layout, it's just not changing the BoM Structure...

If I've helped you out drop the post a like, if I've given you a solution mark as solved. It's us, 'The community' that makes this place work 😄
Message 5 of 12
A.Acheson
in reply to: Josh_Hudson97

"The issue I now have is this doesn't update the BoM structure when using in a factory layout. It will work if I open the part and run it manually but doesn't happen on its own, anyone got any ideas? "

 

Can you give us a screenshot of the context your running it? This is designed for an assembly document opened explicitly meaning it is the top level. but you mentioned a part? Also the rule won't run until you given an event trigger of some kind. One example could be a save event trigger or a parameter change. Wouldn't you be only changing this once? 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 6 of 12
Josh_Hudson97
in reply to: A.Acheson

Hi @A.Acheson,

 

I'm not sure how familiar you are you Autodesk Factory Design? But in simple terms you can build a library of assets (which can contain iLogic) and use these to build up a factory plan.

 

The attached video dhows the rule working when I'm using it in the 'standard' inventor environment. However making that same change within the factory environment doesn't update the BoM Structure. I know the rule runs as the part number changes (done in the same rule) and you can see my iLogic log with some logger.trace bits for reference 

If I've helped you out drop the post a like, if I've given you a solution mark as solved. It's us, 'The community' that makes this place work 😄
Message 7 of 12
A.Acheson
in reply to: Josh_Hudson97

I have no experience in that addin so their might be restrictions. Can you verify its running on the correct Active Document. 

 

MessageBox.Show(ThisApplication.ActiveDocument.FullFileName)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 8 of 12

@A.Acheson Yes you're right! Obvious now you said it haha.

 

It was changing the BoM structure of the layout file in factory (Temp 2 in the video). Not 100% sure how I'll get around that though within Factory, I'll have a think 🤔. It's not as simple as just adding a string location as a file is created each time with a random string suffix added to the file name each time you configure something new in factory.

If I've helped you out drop the post a like, if I've given you a solution mark as solved. It's us, 'The community' that makes this place work 😄
Message 9 of 12

I've just checked an the file name is generated in factory as the rule is running, so... How could I go about changing

 

ThisApplication.ActiveDocument.ComponentDefinition

To something that would reference

ThisDoc.Document

 I'm still finding my feet with this side of iLogic, which I'm sure you can already see 😆.

If I've helped you out drop the post a like, if I've given you a solution mark as solved. It's us, 'The community' that makes this place work 😄
Message 10 of 12

To update this thread for others...

 

I've got it working now. I first tried just setting the active document but that caused error messages when running the rule from my factory layout. I used @JelteDeJong website to help me through, but I needed to set it using Factory document for reasons found on the linked website.

 

My final rule looked looked this and from my limited testing all seems to be working:

''' Useful links for reference in this rule
''' https://forums.autodesk.com/t5/inventor-programming-ilogic/change-bom-structure-of-my-current-assembly/m-p/12532550#M163214 - My Forum Post
''' https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-change-bom-structure/td-p/7439691 - Use to get reference for Component Definition
''' http://hjalte.nl/73-ilogic-rules-and-modelstates - Jelte de Jong website This explains why to use FactoryDocument

' set a reference to the assembly component definintion
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisDoc.FactoryDocument.ComponentDefinition 'By using Factory Document this works

If POST_CENTRES = 2970 Then
	
	iProperties.Value("Project", "Part Number") = "XXF093 2002 11"
	oAsmCompDef.BOMStructure = 51970 'Normal

ElseIf POST_CENTRES = 3570 Then
	
	iProperties.Value("Project", "Part Number") = "XXF093 2002 12"
	oAsmCompDef.BOMStructure = 51970 'Normal
	
ElseIf POST_CENTRES = 4170 Then
	
	iProperties.Value("Project", "Part Number") = "XXF093 2002 13"
	oAsmCompDef.BOMStructure = 51970 'Normal
	
Else
	
	iProperties.Value("Project", "Part Number") = "SPECIAL SALES KIT REQUIRED"
	oAsmCompDef.BOMStructure = 51971 'Phantom
End If
If I've helped you out drop the post a like, if I've given you a solution mark as solved. It's us, 'The community' that makes this place work 😄
Message 11 of 12

I think I've gotten there in the end... I used @JelteDeJong's Website to guide me through (Thank you!) and got the below rule which seems to be working from my limited testing.

 

''' Useful limks for reference in this rule
''' https://forums.autodesk.com/t5/inventor-programming-ilogic/change-bom-structure-of-my-current-assembly/m-p/12532550#M163214 - My Forum Post
''' https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-change-bom-structure/td-p/7439691 - Use to get reference for Component Definition
''' http://hjalte.nl/73-ilogic-rules-and-modelstates - Jelte de Jong website This explains why to use FactoryDocument

' set a reference to the assembly component definintion
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisDoc.FactoryDocument.ComponentDefinition 'By using Factory Document this works

If POST_CENTRES = 2970 Then
	
	iProperties.Value("Project", "Part Number") = "XXF093 2002 11"
	oAsmCompDef.BOMStructure = 51970 'Normal

ElseIf POST_CENTRES = 3570 Then
	
	iProperties.Value("Project", "Part Number") = "XXF093 2002 12"
	oAsmCompDef.BOMStructure = 51970 'Normal
	
ElseIf POST_CENTRES = 4170 Then
	
	iProperties.Value("Project", "Part Number") = "XXF093 2002 13"
	oAsmCompDef.BOMStructure = 51970 'Normal
	
Else
	
	iProperties.Value("Project", "Part Number") = "SPECIAL SALES KIT REQUIRED"
	oAsmCompDef.BOMStructure = 51971 'Phantom
End If

 

If I've helped you out drop the post a like, if I've given you a solution mark as solved. It's us, 'The community' that makes this place work 😄
Message 12 of 12
A.Acheson
in reply to: Josh_Hudson97

I will attempt to explain what is going on here so hopefully you might better understand.

 

To start with in ilogic editor you can use ilogic API and the inventor API. The two are sepearate methods. ILogic API utilize short and concise functions and methods to make it user friendly to non programming users. Meanwhile in the background of this you effectively have the inventor API running.

 

If your a developer or want to engage with more complex elements of the software you would use the inventor API to base your code on. Here is an article that attempts to explain both. 

 

One example on accessing a document.

Ilogic API: ThisDoc.Document

Inventor API: ThisApplication.ActiveDocument

 

These are similar but different ways to access  a document in the ilogic editor. They will perform differently inside ilogic rules vs when used in external rules.

 

So in your case originally you used ....ActiveDocument but this could is likely the top level factory layout document and not assembly document you wanted. Your internal code is now using ThisDoc.... which now targets the assembly document the rule is ending. So in your code your actually using a combination of ilogic API and the Inventor API together which can make troubleshooting more difficult but not impossible.

 

Here is the help page on ThisDoc in the ilogic API.

 

 

 

AAcheson_1-1706885859308.gif

 

FactoryDocument
If the rule is running in a model state member document, this returns the corresponding factory document. Otherwise, in a part or assembly this returns the same object as the Document property. In a drawing, this returns Nothing

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report