Model State Prompt Upon Part Place in Assembly

Model State Prompt Upon Part Place in Assembly

jamesmTKN9N
Contributor Contributor
188 Views
5 Replies
Message 1 of 6

Model State Prompt Upon Part Place in Assembly

jamesmTKN9N
Contributor
Contributor

For context, most of our parts/assemblies have slight variations of each other (ie varying lengths or diameters etc). We've have a base part file that makes up the base geometry and use model states to set the specific dimensions (Base part file = Shaft-X, 6" long shaft = Shaft-6, 8" shaft = Shaft-8, etc). When those parts are checked in to the vault, they are typically checked in under the "[Primary]" model state. When the user goes to place that part into an assembly, the [Primary] part is placed and the user has to check and see if there are other model states for that part for them to configure. If the user does not change the model state for that part, the model would be incorrect & the BOM would not have the correct part number. Is there a way to prompt the user to select any one of the model states that is the [Primary] upon that part being placed in an assembly using iLogic? Also would that same functionality be used for placing assemblies with model states into other assemblies? I've tried a few iLogic scripts and used the "After Open Document" event trigger, but the script is not triggered if the part is already loaded into the cache. For context I'm using Inventor 2025.3, most likely updating to 2026 after the first service pack is released

0 Likes
189 Views
5 Replies
Replies (5)
Message 2 of 6

jnowel
Collaborator
Collaborator

I can't recall how different 2025 vs 2026.
But in INV 2026, you can select the Model State in the "Place Component" Dialog box.

jnowel_0-1769619517441.png


Not sure if that is a good enough "prompt" as it isn't forceful (as the default selection is "Primary")
I imagine you'll want something that won't place the component when it is set at Primary if there are model states available.


you may want to ask @CGBenner to move this post to the Inventor Programming forum for more visibility.

0 Likes
Message 3 of 6

swalton
Mentor
Mentor

iParts/iAssemblies may be useful because they ask the user to select an instance on placement.  They are a bit harder to add additional members than Model States.

 

Consider publishing iParts to Content Center if they don't change much.

 

Vault adds some complexity.  Are you using Vault Pro?  How do you intend to handle revisions to one member but not the other ones? 

Steve Walton
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.

EESignature


Inventor 2025
Vault Professional 2025
0 Likes
Message 4 of 6

jamesmTKN9N
Contributor
Contributor

Yes that is an option in 2025 I believe but not all of our parts & assemblies have model states and since were using the vault, there's an additional button you have to press to get the select model state to show up (not very intuitive & you'll have to remember whether or not that part or assembly has model states or not). Keep in mind we have hundreds of parts & assemblies so making the workflow efficient and user friendly is my goal. 

0 Likes
Message 5 of 6

jamesmTKN9N
Contributor
Contributor

I haven't spent much time with iParts or iAssemblies but the issue with going that direction is we have hundreds of parts & assemblies in the Vault (yes Vault Pro) that would need to be reconfigured if we went in that direction. Parts don't change all that often but assemblies occasionally do. 

 

Our assemblies that have the different model states are essentially like a "family" assembly number (ASS-456-0101-X, where the X designates the length of arm used in the assembly) and all other parts in that assembly are the same so most likely if a change is needed to the -1, it should also be applied to the -4 etc etc. 

 

The issue is not making a prompt that asks the user to select a model state and then activate selected model state, its triggering an iLogic rule when that part is placed in an assembly. You would think that there would be an iLogic event trigger like "Upon Part Placement" or something similar that could be used for a case like this. Hopefully to be added in the coming service packs to 2026.

0 Likes
Message 6 of 6

jnowel
Collaborator
Collaborator

@jamesmTKN9N someone also asked a similar question in the Inventor Programming forum.

Solved: trigger a rule after "Place component" - Autodesk Community

 

if I understand correctly, it should be triggered/run after opening the assy.

editing @WCrihfield provided code, it will look something like this:

Sub Main
	Dim oAsmEvents As AssemblyEvents = ThisApplication.AssemblyEvents
	AddHandler oAsmEvents.OnNewOccurrence, AddressOf oAsmEvents_OnNewOccurrence

	Dim oAppEvents As ApplicationEvents = ThisApplication.ApplicationEvents
	AddHandler oAppEvents.OnCloseDocument, AddressOf ApplicationEvents_OnCloseDocument
End Sub

Public Sub oAsmEvents_OnNewOccurrence(oAsmDoc As AssemblyDocument, oOcc As ComponentOccurrence, oTiming As Inventor.EventTimingEnum, oContext As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum)
	'to make sure the assembly document that the event happened in is the 'local' assembly
	'otherwise don't do anything (don't work for other assembly documents that may also be open)
	'ThisDoc.Document will always refer to the 'local' document, when used in a 'local' rule
	If oAsmDoc Is ThisDoc.Document Then
		'<<<< RUN YOUR RULE FROM WITHIN THIS SUB >>>>
		'iLogicVb.RunRule("RuleName")
		'iLogicVb.RunExternalRule()
		'iLogicVb.Automation.RunRule()
		'iLogicVb.Automation.RunExternalRule()
		'MsgBox("Ran your Rule successfully.",,"")
		If oOcc Is Nothing Then 'this triggers BEFORE placement
			Logger.Info("Preparing to add component")
		Else  'this triggers AFTER placement
			Logger.Info("Added " & oOcc.Name)
		End If
	End If
End Sub

Public Sub ApplicationEvents_OnCloseDocument(oDoc As Inventor._Document, oFullName As String, oTiming As Inventor.EventTimingEnum, oContext As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum)
	If oDoc Is ThisDoc.Document Then
		Dim oAsmEvents As AssemblyEvents = ThisApplication.AssemblyEvents
		Dim oAppEvents As ApplicationEvents = ThisApplication.ApplicationEvents
		RemoveHandler oAsmEvents.OnNewOccurrence, AddressOf oAsmEvents_OnNewOccurrence
		MsgBox("Removed 'OnNewEditObject' Event handler.",,"")
		RemoveHandler oAppEvents.OnCloseDocument, AddressOf ApplicationEvents_OnCloseDocument
		MsgBox("Removed 'OnCloseDocument' Event handler.",,"")
	End If
End Sub

 

0 Likes