Model states - Open with visible false does not ensure that I actually open the document in desired model state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Screencast: https://autode.sk/3tKFzuA
Steps to reproduce the issue:
Open a part and activate model state B, save and close.
Open an assembly containing that part with model state A active (this cause the factory of the part to be present in the Application.Documents list with model state B active)
Execute the attached rule:
open non-visible the part in the master model state.
get from that factory document an iProperty and you'll see that the value is from model state B.
I would like to add some other things:
Open with visible false does not set the Document.Open property to true and this is not changed from previous Inventor, but I don't know it this is correct in Inv 2022.
I got an iProperty just to show the issue, but a more critical api which is not working is ReferencedDocumentDescriptors.
The open visible false issue is the reason behind this bug report ( @m.maertens6DTZT , you can reproduce your problem sistematically if you have the original component that you're iLogic-placing opened in an assembly or a drawing.)
Sub main() Dim alreadyOpenedDOc As Document Try alreadyOpenedDOc = ThisApplication.Documents.ItemByName("path\to\the\part.ipt") Catch End Try Dim doc As Document If alreadyOpenedDOc IsNot Nothing doc = alreadyOpenedDOc MsgBox("ALREADYOPENED" & vbNewLine & doc.FullDocumentName & vbNewLine & " IsModelStateFactory: " & doc.ComponentDefinition.IsModelStateFactory & vbNewLine & " IsModelStateMember: " & doc.ComponentDefinition.IsModelStateMember & vbNewLine & " ModelStateName: " & doc.ModelStateName & vbNewLine & " ActiveModelStateName: " & doc.ComponentDefinition.ModelStates.ActiveModelState.Name & vbNewLine & " Open: " & doc.Open.ToString & vbNewLine & " Is dirty: " & doc.Dirty.ToString) End If doc = ThisApplication.Documents.Open("path\to\the\part.ipt", False) MsgBox(doc.FullDocumentName & vbNewLine & " IsModelStateFactory: " & doc.ComponentDefinition.IsModelStateFactory & vbNewLine & " IsModelStateMember: " & doc.ComponentDefinition.IsModelStateMember & vbNewLine & " ModelStateName: " & doc.ModelStateName & vbNewLine & " ActiveModelStateName: " & doc.ComponentDefinition.ModelStates.ActiveModelState.Name & vbNewLine & " Open: " & doc.Open.ToString & vbNewLine & " Is dirty: " & doc.Dirty.ToString) Dim props As PropertySet = doc.PropertySets.Item("Inventor Summary Information") MsgBox("TITLE: " & props.Item("Title").Value) ' MsgBox(doc.ReferencedDocumentDescriptors.Count()) ' For Each dd As DocumentDescriptor In doc.ReferencedDocumentDescriptors ' MsgBox(dd.FullDocumentName) ' If dd.ReferenceMissing ' MsgBox("MISSING") ' End If ' Next End Sub