Model States and Changing iProperties with iLogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Background
I have an iLogic that creates a custom form for the user to update iProperties on a design copied file without having to go into the iProperties to do so. Some properties are prompted from the user and others are calculated using the file name. This iLogic is run from the .dwg file and changes iProperties for both the model document and the .dwg.
Problem
If the design copied file has model states, only the master model state of the model document has the iProperties changed to match the user input. The others are left unchanged, regardless if the edit scope is individual or factory. I attempted to address this by having the code loop through model states, activating the model state and changing the properties, and at the end activating the original model state again. However, this throws an error (probably due to the code running from the .dwg instead of the .iam or .ipt)
Question
Is there a way to change model state iProperties from the .dwg? Does each model state have its own Document object? I tried looping through the model states and using ModelState.Document in place of ModelDocument in the code below, but it threw an error. Surely there has to be a way to manipulate model state iProperties; if not, then model states are entirely unusable (which is already somewhat the case in Inventor 2022 due to the whole 0 quantity BOM issue)
Here is a code snippet of how I'm changing the iProperties
With ModelDocument
.PropertySets("Design Tracking Properties")("Description").Value = Results.Item("Description")
.PropertySets("Design Tracking Properties")("Designer").Value = oName ' set the designer iProperty
.PropertySets("Inventor Summary Information")("Author").Value = oName ' set the Author iProperty
.PropertySets("Design Tracking Properties")("Creation Time").Value = DateTime.Now ' set creation time to the current time
.PropertySets("Inventor Summary Information")("Revision Number").Value = "-" ' set to initial revision
End With