Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
In an assembly I place a part and derive it, based in on this sample.
This creates a new modelstate for the substitute part.
Next I would like to switch back to the master modelstate and delete all other modelstates.
This is the part of my code:
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
ThisApplication.SilentOperation = True
For Each oMS As ModelState In oAsmCompDef.ModelStates
If oMS.ModelStateType = ModelStateTypeEnum.kMasterModelStateType Then
oMS.Activate
End If
Next
ThisApplication.SilentOperation = False
ThisApplication.ActiveDocument.update2()
ThisApplication.ActiveDocument.rebuild2()
For Each oMS As ModelState In oAsmCompDef.ModelStates
If oMS.ModelStateType = ModelStateTypeEnum.kSubstituteModelStateType Then
Try
oMS.Delete
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
NextThe delete command throughs an error. When I debug the code I can see that this occures because the switch to the master modelstate is not yet over.
If I stop the code, go back to the assembly and start the code again, it works.
How can I update the assembly after setting the master modelstate to active?
This code was updated from Inventor 2021, where I used displayreprensentations, and everything worked as expected.
Solved! Go to Solution.