- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Having some issues running rules/setting parameters on the new active model state
I have used the solution code with minor alterations:
Dim doc As AssemblyDocument = ThisDoc.Document Dim occ As ComponentOccurrence '= doc.ComponentDefinition.Occurrences.Item(1) Dim oName = "COURSE 1 STEEL TANK SHEET:8" For Each occ In doc.ComponentDefinition.Occurrences If occ.Name = oName Then 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 = "N1" Dim modelState As ModelState = modelStates.Add() modelState.Name = newModelStateName modelState.Activate() occ.ActiveModelState = newModelStateName End If Next ilogicVb.RunRule("COURSE 1 STEEL TANK SHEET:8", "ManwayCutOut")
Here it goes through each occurrence and looks for 'COURSE 1 STEEL TANK SHEET:8' which is the occurrence of the part that I want on the different model state. (So part such as COURSE 1 STEEL TANK SHEET:1 will still be set to Master model state.)
The issue is that it will not then run the last line. We get a lovely unspecified error. The rule 'ManwayCutOut' does exist in this part. If I go and delete the new ModelState and have every thing back on Master I can run this one line fine...
Had issues with the following line too
Parameter("COURSE 1 STEEL TANK SHEET:" & BespokeSheet, "ManwayType") = MWAY_TYPEWhich again if I delete the new ModelState and have everything back on Master I can run both the parameter line and the ilogicvb.runrule line.
Tried a different approach with setting everything to the new Model State and then running the issue lines but still get the unspecified error...
Any advise/help??