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 Drive Part Model Stage using iLogic

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
frahaman7SKBG
568 Views, 4 Replies

Change Drive Part Model Stage using iLogic

Hi there, 

 

I was wondering if anyone knows how to change a Drive Part's Model state using iLogic?

 

I would like to use iLogic to go into each individual Drive Part in an assembly and change the Model State of each part.  Currently, I only know how to do it manually, but I have over 50 parts and it can take lots of time. 

 

frahaman7SKBG_0-1632424300712.png

 

Labels (1)
4 REPLIES 4
Message 2 of 5
JelteDeJong
in reply to: frahaman7SKBG

I found the following code and I would expect that this would do the trick:

Dim doc As PartDocument = ThisDoc.Document
Dim comp As DerivedPartComponent = doc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1)
comp.Definition.ActiveModelState = "Master"

' and check if the "ActiveModelState" is changed. 
MsgBox(comp.Definition.ActiveModelState)

But if I run this rule the ModelState will not change. Not sure what I do wrong or if this is a bug (@MjDeck  ).

Jelte de Jong
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


Blog: hjalte.nl - github.com

Message 3 of 5
frahaman7SKBG
in reply to: JelteDeJong

Thank you @JelteDeJong for your reply. Your snippet is definitely a start. It is able to grab the ActiveModelState.

Does anyone here know how to ChangeModelState?
Message 4 of 5
MjDeck
in reply to: JelteDeJong

You have to add an extra step. Here's sample code for a single part. This would have to be modified to make it run on multiple parts in an assembly.

Dim doc As PartDocument = ThisDoc.Document
Dim comp As DerivedPartComponent = doc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1)
Dim derivedDef = comp.Definition
Logger.Info("current model state = {0}", derivedDef.ActiveModelState)
Dim stateWanted = "Model State1"
If (derivedDef.ActiveModelState <> stateWanted) Then
	derivedDef.ActiveModelState = stateWanted
	comp.Definition = derivedDef ' apply the modified definition back to the DerivedPartComponent
End If

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 5 of 5
frahaman7SKBG
in reply to: MjDeck

Thank you @MjDeck. I was able to take your snippet and modify it to make it work.

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report