Modifying files with ModelStates via Apprentice not possible

Modifying files with ModelStates via Apprentice not possible

nboelens
Contributor Contributor
702 Views
5 Replies
Message 1 of 6

Modifying files with ModelStates via Apprentice not possible

nboelens
Contributor
Contributor

We have been using an Excel/VBA copy-tool to copy drawings with Apprentice Server for many years. This tool automates many tasks including changing iProperties and updating links.

 

Since we upgraded Inventor last week from 2020 to 2024 we get an error whenever we try to use this tool on assemblies that have got ModelStates. Error example: "Error -2147467259 (80004005) Method Value of object Property failed".

 

During debugging I can see that IsModifiable is False (in Apprentice). When I remove the extra Model States in Inventor, save the file, and open it again with Apprentice, I can see that IsModifiable has changed to True. Therefore I assume the Model State is responsible for the errors we are getting.

 

There are similar posts on the forum with this problem, but I haven't seen a solution that works for us. One of the proposed solutions mentions setting Toggle Edit Scope to Factory Scope. I can't do this, the only available options are kEditAllMembers and kEditAllMembers. I did try to change Toggle Edit Scope to All Model States in Inventor, but with no success, in Apprentice IsModifiable remains False and the error also remains.

 

Surprisingly Design Assistant doesn't have any issues with Model States. I have tried different situations (with/without ModelStates, Primary active/Custom active, All Model States active/Model State Only active) and every time it is possible to edit iProperties with Design Assistant. This makes me think there is a solution possible, I just haven't found it yet, and I could use some help on this.

 

How can we overcome this issue and make it possible again to use our Excel/VBA copy-tool on files with Model States?

 

As a workaround the tool now skips files with ModelStates, which means manually changing iProperties and exchanging links, but this is a very undesirable situation.

 

Thanks in advance,

Niels

 

0 Likes
Accepted solutions (1)
703 Views
5 Replies
Replies (5)
Message 2 of 6

JelteDeJong
Mentor
Mentor
Accepted solution

You might want to read this:

https://adndevblog.typepad.com/manufacturing/2022/05/porting-guide-from-level-of-details-to-model-st...

 

just some quotes:

The ApprenticeServerDocument.PropertySets currently just return the iProperty of the active model state, and the model state level iProperty is regarded as the model data so Apprentice can’t edit at present.

 

If you want to edit the iProperty of a custom model state, it is recommended to use Inventor Server or Inventor instead.

 

Any Inventor 2022 part with an added model state causes IsModifiable value to be true and prevents any updates of iproperties with apprentice server.

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

0 Likes
Message 3 of 6

nboelens
Contributor
Contributor

Thank you for the link, this clarifies some of the question I had.

 

Changing PropertySets to FilePropertySets fixed the error messages we got. Our copy-tool can be used again, but unfortunately updating the iProperties appears not to be possible anymore when a ModelState is present.

 

I am still somewhat confused about the explanation they give about editing iProperties (see below). It seems the 2022.1 update made it possible to edit the iProperties again, but even with the FilePropertySets object the changes I make are not saved to the iProperties.

 

A new API ApprenticeServerDocument.FilePropertySets is exposed in Inventor 2022.1 release, and this FilePropertySets is File level iProperty, and it will return the same property values as the iProperty of master model state, and you can also change the property values in FilePropertySet.  If you want to edit the iProperty of a custom model state, it is recommended to use Inventor Server or Inventor instead.

 

And

 

The legacy ApprenticeServerDocument.PropertySets does not work in ApprenticeServer anymore when there is custom model state, and in Inventor 2022.1 we introduced a new ApprenticeServerDocument.FilePropertySets instead, so you should make use of the new API to update the file level iProperties. 

0 Likes
Message 4 of 6

Frederick_Law
Mentor
Mentor

@nboelens wrote:

 

A new API ApprenticeServerDocument.FilePropertySets is exposed in Inventor 2022.1 release, and this FilePropertySets is File level iProperty, and it will return the same property values as the iProperty of master model state, and you can also change the property values in FilePropertySet.  If you want to edit the iProperty of a custom model state, it is recommended to use Inventor Server or Inventor instead.

 

 


 

0 Likes
Message 5 of 6

nboelens
Contributor
Contributor

Thank you for bringing the Master model state to my attention. This led me to the solution for storing the iProperties with Apprentice.

 

After using FilePropertySets instead of PropertySets everything seemed to work as before, except the edited iProperties were not save to the document. I have now added oApprDoc.FilePropertySets.FlushToFile to write the changed iProperties to the file and this solved the last issue I had with saving the changes.

 

If I understand it correctly there now is:

  • Model State Factory Document (a.k.a. master model state / primary model state) which iProperties can be read and written with Apprentice via FilePropertySets + FlushToFile
  • Model State Member Document(s) (a.k.a. custom model state) which iProperties can only be read with Apprentice via PropertySets, and only the currently active ModelState is visible.
0 Likes
Message 6 of 6

WCrihfield
Mentor
Mentor

Hi @nboelens.  I am not super familiar with Apprentice, but on the Inventor side, there is only a ModelState 'factory' when there is more than just the original ModelState present.  And the 'factory' just seems to be whichever ModelState happens to currently be 'active' at that moment.  Because when the MemberEditScope setting is set to 'active member only' setting, you can only edit whichever ModelState that is currently active.  It is the same when working on that file by code.  The inactive ModelStates are the 'member' ones, and they can be read, but not edited, while in that edit mode.  So, in Inventor, we must first activate the ModelState that we want to edit, then edit it.  Or, we can edit the ModelStateTable either through its properties, or by using the spreadsheet option (Excel), which can also be done by code.  But I don't know about all of that from the perspective of Apprentice.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)