How to enable or disable "Substitute" Part Model

How to enable or disable "Substitute" Part Model

ngdnam88
Advocate Advocate
225 Views
3 Replies
Message 1 of 4

How to enable or disable "Substitute" Part Model

ngdnam88
Advocate
Advocate

Dears,

Could you please help me how to enable/disable the "Substitute" function via iLogic/API?

ngnam1988_0-1736935063767.png

Thanks!

0 Likes
Accepted solutions (1)
226 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @ngdnam88.  I am not familiar with that, but I do know the command that gets executed when you choose that item in the right-click menu is named "CMxSubstituteCmd".  You may be able to simulate choosing that item in the right-click menu by using the

ThisApplication.CommandManager.ControlDefinitions.Item("CMxSubstituteCmd").Execute()

line of code.

 

However, since I am not familiar with it, I do not know if there is a Inventor API equivalent to executing the command.  It makes me think of the ModelStates though.  When we have an assembly open, and right click on the main ModelStates folder, it gives us the 'expandable' option named 'New Substitute', which has 3 sub options named 'Derive Assembly', 'Simplify', and 'Select Part File'.  I pretty much never use those, but this sort of sounds like that last option, but maybe initiating it in reverse order (from the part, instead of from the assembly).  Not sure though.

WCrihfield_0-1736953122730.png

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 4

C_Haines_ENG
Collaborator
Collaborator

This example rule works but only if the substitute property was turned on at least once before. Not sure why it doesn't work beforehand.

Sub Main
	
	Dim oDoc As PartDocument = ThisDoc.Document
	
	oDoc.BrowserPanes("Model").TopNode.DoSelect
	ThisApplication.CommandManager.ControlDefinitions.Item("CMxSubstituteCmd").Execute

End Sub

 

0 Likes
Message 4 of 4

C_Haines_ENG
Collaborator
Collaborator
Accepted solution

Actually this is just a property of a partdocument object. Couldn't get easier!

 

Sub Main
	
	Dim oDoc As PartDocument = ThisDoc.Document
	
	oDoc.IsSubstitutePart = True

End Sub