Update parameter, using iLogic, in all modelstates

Update parameter, using iLogic, in all modelstates

JelteDeJong
Mentor Mentor
4,983 Views
29 Replies
Message 1 of 30

Update parameter, using iLogic, in all modelstates

JelteDeJong
Mentor
Mentor

This seems like a silly question. But I'm moving from Inventor 2021 to Inventor 2023. And now I have to deal with model states. For my generator, I have many documents with even more iLogic rules. And all of them update parameters like this:

 

Parameter("test") = 123

 

Many assemblies have 2 "Levels of details", which get converted to model states. (The parameters in those model states need to be the same. I need to keep the same functionality as the "Levels of details".)

And that works if the "edit scope" is set to "All model states". But users can change that and of course, there are legit reasons for that. (That is the point of "Levels of details" and model states.)

I know that I can solve this with 1 line of extra code like this:

ThisDoc.FactoryDocument.ComponentDefinition.ModelStates.MemberEditScope = MemberEditScopeEnum.kEditAllMembers

So here is the real problem.

  • I don't like this very long line of code.
    • I would like something simple as:  ThisDoc.EditAllModelStates()
    • Or better no code at all just a setting in the iLogic form...
  • I have to do a lot of rework on my generator models.

Is there some setting that I did not find or has someone else found a solution for a similar problem?

 

 

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

4,984 Views
29 Replies
Replies (29)
Message 21 of 30

chrisw01a
Collaborator
Collaborator
Well I added it manually and it works great! I do not understand why they would do this...
The Inventor API does not have a comparable property?
Message 22 of 30

chrisw01a
Collaborator
Collaborator

...

0 Likes
Message 23 of 30

WCrihfield
Mentor
Mentor

Thank you for confirming that.  I know that there is not an API equivalent to that main setting, but there are definitely other ways of ensuring that edits get recorded to the specific (or all) ModelStates of a file.  I may start using that technique sometime in the near future, once I am able to do more local testing with it.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 24 of 30

chrisw01a
Collaborator
Collaborator

Wesley,
It seems to work as expected with my documents.

 

In your experience, what is the simplest way to do this using Apprentice Server? I am setting some iProperties with a VB.NET program and will need to add this so I am modifying all model states.

 

'Get the iProperty "part number" from the current document.
Dim partNumber As Inventor.Property = openedDoc.FilePropertySets.Item("Design Tracking Properties").Item("Part Number")
'Set the partnumber field
partNumber.Value = "PART_NUMBER"

 

Thanks for your input! 

0 Likes
Message 25 of 30

WCrihfield
Mentor
Mentor

I honestly do not have any experience using Apprentice.  I know it is generally used through an external EXE type application for doing some of the lighter functionality of Inventor, and I know that it has some limitations compared to regular Inventor, but it sounds like they have been making improvements on its functionality lately.  I am not even sure if it can work with ModelStates yet or not.  If it can, then you would want to go to the ApprenticeServerDocument.ComponentDefinition.ModelStates.MemberEditScope property to access that setting.  But setting that will only control that one file, not all files.  Under the main application is the ModelStatesEvents API object, but not an application wide MemberEditScope (that I know of).  Monitoring that event will let you know when any ModelState is activated, when one is deleted, or if a new one is created.  If you always want to be editing all ModelStates, instead of the active one, then you might be able to create a custom event handler code to react to when any ModelState is created, and / or activated, then make sure that scope is still set to all members.  That is just a theory at this point though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 26 of 30

chrisw01a
Collaborator
Collaborator

I would like to point out that it seems as if the "Part Number" field must be the same on all model states or this (

iLogicVb.MemberEditScope = MemberEditScopeEnum.kEditAllMembers

) doesn't work. This is so confusing!

 

chrisw01a_0-1697213574769.png

 

0 Likes
Message 27 of 30

chrisw01a
Collaborator
Collaborator

Looks like it does not work with Apprentice. Now what

 

chrisw01a_0-1697215355862.png

 

0 Likes
Message 28 of 30

WCrihfield
Mentor
Mentor

Is it just that final step of setting that property that throws the exception, or is it simply accessing the ModelStates at all that throws the exception?

 

This is just a guess, since I can not test it, but if you can access the names of the ModelStates that are present in each file, you could try specifying each document by its FullDocumentName.  In the case of files containing more than just the one original ModelState, each ModelState represents another Document within the file, and the FullDocumentName will start with the FullFileName value, then will be followed by the "<" character, then the name of the ModelState, then the ">" symbol.  When using the Documents.Open methods, it encourages us to use the FullDocumentName, instead of the FullFileName, to ensure you are accessing the specific version you want.  You may be able to use that detail somehow in your workflow.  Once you have a reference to a document that was obtained through that special specification, you should be working directly with that one ModelState version document.  I know this is not the same as editing all members at once, like you want, but it may be something to look into.

 

The next thing you could attempt is to access the ModelStates.ModelStatesTable or the ModelStates.ExcelWorkSheet.  About the only thing in the table that you may have Read/Write access to are the ModelStatesTableCell.Value property.  But if it will let you do that, you can edit all ModelStates at the same time by editing every cell in that same column (besides the header) the same way.  However, navigating that table by its column headers can be tricky, where iProperties are involved.  To see what I mean, it is best to manually open that table and look at the column headers yourself.  When the column is for an iProperty, there will be an extra specification after the name of the property in the header, to indicate which PropertySet the property is from, enclosed within "[" & "]" symbols.  But to avoid that, you could use If oCol.Header.Contains(property name), or StartsWith().

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 29 of 30

chrisw01a
Collaborator
Collaborator

Wesley, have you experimented with this any more? Do you know if perhaps they added this (

MemberEditScopeEnum.kEditAllMembers

) API functionality in version 2025?

0 Likes
Message 30 of 30

WCrihfield
Mentor
Mentor

Hi @chrisw01a.  I am still using Inventor Pro 2024.3.1 at the moment.  I have used that Enum setting directly from the ModelStates object (ModelStates.MemberEditScope), using Inventor API code processes, and it seems to work OK for what I need it for.  (to clarify...not through Apprentice, just through Inventor directly)

 

However, I have not yet been able to test the newer 'iLogic shortcut tools' (listed below) which have incorporated setting that Enum for their own separate functionality.  They first became available in 2024, but they required an operating system environment variable be created and/or set, before they would function properly.  And our corporate IT department said they needed to 'look into it further' before creating/changing that environment variable on my computer...but of course they never 'finished looking into it', so I never got it set-up properly.  I can only assume that when you install Inventor Pro 2025, maybe the installation process creates/sets that environment variable for us automatically, or maybe just eliminates the need for it...I'm not 100% sure.

 

The 'iLogic tools' I am talking about there are the following ones:

iLogicVb.MemberEditScope (aka ILowLevelSupport.MemberEditScope)

Component.MemberEditScope (aka ICadComponent.MemberEditScope) 

Feature.MemberEditScope (aka ICadFeature.MemberEditScope) 

iProperties.MemberEditScope (aka IiProperties.MemberEditScope) 

Joint.MemberEditScope (aka IAssemJoint.MemberEditScope) 

Parameter.MemberEditScope (aka IParamDynamic.MemberEditScope) 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes