Link Multiple Model States at Once

Link Multiple Model States at Once

bltrubey87
Contributor Contributor
341 Views
8 Replies
Message 1 of 9

Link Multiple Model States at Once

bltrubey87
Contributor
Contributor

Is there a means of linking multiple model states at once?

 

I have a pallet assembly with 122 different parts. Each part is unique and requires it's own model state. Each of these parts needs to be shown on the pallet in each model state in multiple machines. I have set up the pallets and machines to all have the same model state names and I'd like to link them. Is there a means of linking all of the model states at once or do I need to link each model state individually?

 

For example if I try to use the link model states tool, I can only select one model state at a time. I'd like to do something like hold the shift key down and highlight multiple models states and link them.

0 Likes
342 Views
8 Replies
Replies (8)
Message 2 of 9

hollypapp65
Advocate
Advocate

Just activate modelstate for each part in the assembly.

122 parts, 122 modelstate.

 

"Link" will activate same name modelstate.

0 Likes
Message 3 of 9

bltrubey87
Contributor
Contributor

I'll go ahead and let your reading comprehension instructor cover their face in shame. 

0 Likes
Message 4 of 9

kacper.suchomski
Mentor
Mentor
Dim oADoc As AssemblyDocument = ThisDoc.FactoryDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oOccs As ComponentOccurrences = oADef.Occurrences
Dim oMSs As ModelStates = oADef.ModelStates
Dim oOrigActivMS As ModelState = oMSs.ActiveModelState
oMSs.MemberEditScope = MemberEditScopeEnum.kEditActiveMember
For Each oMS As ModelState In oMSs
	oMS.Activate
	For Each oOcc As ComponentOccurrence In oOccs
		If oOcc.Suppressed Then Continue For 'else unsuppress, change it, then suppress again
		If TypeOf oOcc.Definition Is VirtualComponentDefinition Then Continue For
		If TypeOf oOcc.Definition Is WeldsComponentDefinition Then Continue For
		oOcc.ActiveModelState = oMS.Name
	Next 'oOcc
Next 'oMS
oOrigActivMS.Activate
oADoc.Update

 

Code by @WCrihfield 


Kacper Suchomski

EESignature


YouTube - Inventor tutorials | LinkedIn | Instagram

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 5 of 9

johnsonshiue
Community Manager
Community Manager

Hi! You may try using "Link Model States" tool in Productivity section in the Assembly ribbon.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 6 of 9

SharkDesign
Mentor
Mentor

If your structure is flat, use Johnson's method, otherwise you need the iLogic code. Link Model states only works for one level of the structure and won't drill down through the entire assembly. 

 

 

  Inventor Certified Professional
0 Likes
Message 7 of 9

bltrubey87
Contributor
Contributor

 This code did not work. I get an error message on line 13. Please reference the attached screenshot. It does not matter if I have edit member scope or edit factory scope enabled, I get the same error.

 

Thank you for a helpful reply though, I appreciate it. Based on the other replies you are the only one that actually read my post.

 

I'll just roll with this is yet another short coming of this software and I'll be stuck linking each model state individually rather than en masse.

0 Likes
Message 8 of 9

kacper.suchomski
Mentor
Mentor

I tested this code on my files before I shared it and it worked. If so, there are some details about your project that prevent you from working with this code. To solve them, we need to understand your project better.


Kacper Suchomski

EESignature


YouTube - Inventor tutorials | LinkedIn | Instagram

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 9 of 9

WCrihfield
Mentor
Mentor

Also, if going the code based automation route, there are 'events' that we can 'listen for' and react to, which could be used to run some code every time the event happens.  The number of events that we can access/use through Inventor's API is limited, but the short list of events you see in the 'iLogic Event Triggers' dialog are only a small sampling which the iLogic add-in has made it easier for us to use, without having to know that much about how it works behind the scenes.

For example:

  • Could 'listen for' when a different ModelState gets activated, then:
    • Find a DVR (DesignViewRepresentation) in that same document, with the same name, then activate that also (simulating a 'Link' between the ModelState & DVR that way).
    • If in an assembly, could iterate through all occurrences, try to find ModelStates for them with same name, if so, activate them (simulating a 'Link')
  • Could 'listen for' when a different DVR gets activated, then:
    • Try to activate a ModelState with the same name.
    • Try to push that DVR change to all top level components, if it happened in an assembly.
  • Could listen for when the 'member/factory edit scope' status gets toggled between 'active member only' and 'factory scope / all members' status, but the latest updates to Inventor has already added more notifications and options in that area, so not as popular now as it was in the 2022-2023-2024 releases of Inventor.

Just food for thought.

I have helped others on the Inventor iLogic forum develop code based solutions for similar automated processes, so there is definitely some potential in those areas.  When 'custom' events (ones not listed in the iLogic Event Triggers dialog) get involved, then it is usually best to create an Inventor add-in to 'handle' (listen for & react to) those events.  Add-ins usually load automatically when Inventor starts, then remain available/running/active in the background, reacting to events or custom user interface element interactions.  Creating add-ins is not an option for some though (like me), so well designed external iLogic rules can sometimes be used to take advantage of those types of resources that have been made available to us.  When using iLogic rules though, we only get access to them after Inventor creates or opens the first document, and only remain available while there are some documents open, and they must be 'ran' before they will take effect or do something, but can be ran by events also.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)