Set Inventor Model State Edit Factory Scope as default

Set Inventor Model State Edit Factory Scope as default

joanromero2F9DN
Explorer Explorer
1,933 Views
7 Replies
Message 1 of 8

Set Inventor Model State Edit Factory Scope as default

joanromero2F9DN
Explorer
Explorer

Hi, 

I'm in a project related to different model states, this project will be edited by many people and I don't want it to create troubles. 

 

The ipt that I'm creating has 3 model states which must be always related (having the Edit Factory Scope active). I've been looking everywhere and I haven't found the way to set that, every time you run the rule, the edit factory scope gets activated.

 

In case that this is not possible, I would like to create a msgbox with a notification every time the Edit Member Scope gets activated.

 

Thank you,

0 Likes
Accepted solutions (1)
1,934 Views
7 Replies
Replies (7)
Message 2 of 8

Frederick_Law
Mentor
Mentor

In factory scope, when user edit Part Number, all member will have same Part Number.

Same when user change a dimension.

0 Likes
Message 3 of 8

joanromero2F9DN
Explorer
Explorer

I provably haven't explained correctly, my question is how can I make to always set the "Edit Factory Scope" when executing a rule using iLogic.

0 Likes
Message 4 of 8

Frederick_Law
Mentor
Mentor

Ok, that make more sense.

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-BAFCA92B-9EBE-4BEE-AB1D-E09E2A4158C5

 

ModelStates.MemberEditScope = kEditAllMembers

ModelStates.MemberEditScope = kEditActiveMember

0 Likes
Message 5 of 8

joanromero2F9DN
Explorer
Explorer

Nice, now I have a problem which is an error that says that "ModelStates" is not declared. Do you know how to fix it?

joanromero2F9DN_1-1690902504371.png

 

Thank you so much for your help.

0 Likes
Message 6 of 8

WCrihfield
Mentor
Mentor

Hi @joanromero2F9DN.  You can't just use those two lines of code directly in a rule.  You have to get to the ModelStates object of the document first, then set the value of the MemberEditScope property of that ModelStates object.  The ModelStates object is located under the ComponentDefinition (PartComponentDefinition.ModelStates or AssemblyComponentDefinition.ModelStates), and the ComponentDefinition is located under the PartDocument or AssemblyDocument objects.  But if your rules are very simple, and only use simple iLogic shortcut snippets, you may be able to simply use this one line of code to fix the issue:

iLogicVb.MemberEditScope = MemberEditScopeEnum.kEditAllMembers

That line will effect how the iLogic snippets like Parameter(), iProperties.Value(), Component.IsActive(), and similar lines of code will behave.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 8

joanromero2F9DN
Explorer
Explorer
I understand that I should define the "MemberEditScope" and the "MemberEditScopeEnum" before this code but I'm not experienced in ilogic and I don't know how to do so.
Thank you for your help
0 Likes
Message 8 of 8

WCrihfield
Mentor
Mentor
Accepted solution

Hi @joanromero2F9DN.  Here is a simple iLogic rule that only contains some starter code right now.  It first makes sure that we are working with a Part type document (not an assembly or drawing).  Then it makes sure we are working with the 'factory' document, if one exists.  There will only be a factory document when there are at least 2 ModelStates (the original one, plus at least one more).  When a there is a factory document, that is the only one that is Read/Write, while the ModelState 'member' documents will be ReadOnly.  The factory document is simply the document referenced by the 'active' ModelState.  Then it gets the ModelStates object within the part.  Then it sets the MemberEditScope to the 'All Members' variation.  The all members variation is the same as the factory scope.  After that point, you should be able to fill in the rest of your code past that point, but before the End Sub key phrase.

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
		MsgBox("A Part Document must be active for this rule to work. Exiting.", vbCritical, "")
		Exit Sub
	End If
	Dim oPDoc As PartDocument = ThisDoc.FactoryDocument
	Dim oMSs As ModelStates = oPDoc.ComponentDefinition.ModelStates
	oMSs.MemberEditScope = MemberEditScopeEnum.kEditAllMembers
	'the rest of your code below this point, but before End Sub
	
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)