Thought it was out of place 🙂
Still having issues with getting the rule to run, definitely need to go back to approaching it from assembly level?
So just to refresh:
We have an assembly with duplications of the same part.
We are selecting part variation 'COURSE 1 STEEL TANK SHEET:8'.
We are creating a new model state within this part called N1.
We are activating this model state on just this variation, the other parts are still set to Master. (All this is successful!)
Then we are wanting to run a rule within COURSE 1 STEEL TANK SHEET:8 while it is on model state N1...
This rule is to unsuppress features so that N1 model state differs from the Master model state.
This can all be done manually but we want to have it all automatic...
This works to create the N1 model state within COURSE 1 STEEL TANK SHEET:8
Dim doc As AssemblyDocument = ThisDoc.Document
oName = "COURSE 1 STEEL TANK SHEET:8"
occ = doc.ComponentDefinition.Occurrences.ItemByName(oName)
Dim facDoc As PartDocument = occ.Definition.Document
oPCD = facDoc.ComponentDefinition
If oPCD.IsModelStateMember Then
facDoc = oPCD.FactoryDocument
End If
oMStates = oPCD.ModelStates
newModelStateName = "N1"
oMState = oMStates.Add(newModelStateName)
oMState.Activate()
occ.ActiveModelState = newModelStateName
However this line will not run (when added at the end):
iLogicVb.RunRule(oName, "ManwayCutOut")
So attempted:
Dim doc As AssemblyDocument = ThisDoc.Document
oName = "COURSE 1 STEEL TANK SHEET:8"
occ = doc.ComponentDefinition.Occurrences.ItemByName(oName)
Dim facDoc As PartDocument = occ.Definition.Document
oPCD = facDoc.ComponentDefinition
If oPCD.IsModelStateMember Then
facDoc = oPCD.FactoryDocument
End If
oMStates = oPCD.ModelStates
newModelStateName = "N1"
oMState = oMStates.Add(newModelStateName)
oMState.Activate()
occ.ActiveModelState = newModelStateName
facDoc.Activate
iLogicVb.RunRule(oName, "ManwayCutOut")
're-activate the main assembly afterwards, if needed
'but test both ways, in case more time is needed for the rule to do its thing
'doc.Activate
But the iLogicVb.RunRule(oName, "ManwayCutOut") still will not run.
And I can not work with having the COURSE 1 STEEL TANK SHEET:8 part visibly active along side the main assembly.
Then we tried changing the ManwayCutOut rule but this doesn't fix it as the call from the higher level rule just does not work.
I tried a test:
iLogicVb.RunRule(oName, "TEST")
Run a rule in COURSE 1 STEEL TANK SHEET:8 while N1 Model State is active where TEST had the following code:
MessageBox.Show("WORKING")
But this will not even run...
So I believe the runrule triggger is not working due to the activity state, so can we make the COURSE 1 STEEL TANK SHEET:8 active without it being visibly active??
I hope this is clear.
Thanks