10-26-2021
11:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-26-2021
11:42 AM
This might get you closer to your goal.
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
'define the variable "oName"
oName = "ModelState1"
For Each oOcc As ComponentOccurrence In oADoc.ComponentDefinition.Occurrences
If TypeOf oOcc.Definition Is PartComponentDefinition Then
Dim oPDef As PartComponentDefinition = oOcc.Definition
Dim oFound As Boolean = False
For Each oMS As ModelState In oPDef.ModelStates
If oMS.Name = oName Then
oFound = True
Exit For 'found it, so don't create it
End If
Next
If oFound = False Then
'did not find it, so create it
oPDef.ModelStates.Add(oName)
End If
oOcc.ActiveModelState = oName
End If
Next
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS
or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)