10-26-2021
12:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-26-2021
12:10 PM
I see @WCrihfield was just a bit faster than me but here is my approach.
Dim doc As AssemblyDocument = ThisDoc.Document Dim occ As ComponentOccurrence = doc.ComponentDefinition.Occurrences.Item(1) Dim facDoc As PartDocument = occ.Definition.Document If (facDoc.ComponentDefinition.IsModelStateMember) Then facDoc = facDoc.ComponentDefinition.FactoryDocument End If Dim modelStates As ModelStates = facDoc.ComponentDefinition.ModelStates Dim newModelStateName = "YourNameHere" Dim modelState As ModelState = modelStates.Add() modelState.Name = newModelStateName modelState.Activate() occ.ActiveModelState = newModelStateName
if you want to know why I find the factory document first then you can read my blog post on that topic.
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.
Blog: hjalte.nl - github.com