- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am running into this weird issue, where I am trying to run a rule that creates a new model state in a part. when I run the rule form the part it perfectly runs ok, but when I run it from the assembly here is what happens :
when you run it from an assembly for the first time it runs , no problem
but when you run it again form the assembly , it fails "unexpected error" , and can not pass the parameters from the assembly to the part.
I could get around this issue partially by passing the parameters to a master layout which then is derived into the part , but still get error running the second code below from the assembly.
can you please give me a simple example of adding modelstate to a part from an assembly by passing a parameter to the part which works more than once (I mean just the first time 🙂 ) ?
Thanks for your support
Ali
Dim oDoc As PartDocument
oDoc=ThisDoc.ModelDocument
Dim oPartCompDef As PartComponentDefinition
oPartCompDef = oDoc.ComponentDefinition
Dim oStates As ModelStates
oStates = oPartCompDef.ModelStates
Dim oModelState As ModelState
'create New set of ModelState
If SnapRing = 1 ul Then
oName = "Hub-" & HID & "-" & HThickness & "-" & HDepth & "_S"
Else
oName = "Hub-" & HID & "-" & HThickness & "-" & HDepth
End If
'Check for existance
For Each oModelState In oStates
If oModelState.Name = oName Then
MStateExist = True
MessageBox.Show("Model State Exist")
Exit For
Else
MstateExist = False
End If
Next
Try
oModelState = oDoc.ComponentDefinition.ModelStates.Add(oName)
ThisDoc.ActiveModelState = oName
MessageBox.Show("Model State Created")
Catch
End Try
iLogicVb.RunRule("Reset Model State")
Dim oDoc As PartDocument
oDoc=ThisDoc.ModelDocument
oDoc.ComponentDefinition.ModelStates(1).Activate
Solved! Go to Solution.