- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
OK. So in this case, the info in that other tab wasn't that helpful after all. But after seeing your other rule, I can instantly see why it is having problems. You are using the unquoted names of local parameters and the Feature.IsActive() iLogic snippet without specifying a target component name or document name. That set-up is usually great for local rules, but when you run that rule remotely, while another document is the 'active' document, it may cause problems. I'm not 100% sure whether the Feature.IsActive() iLogic snippet targets the 'active' document or the 'local' document by default, when you don't specify a component name or document name as the first input variable. I assume it is targeting the 'active' document though. And in this case, the main assembly is still the 'active' document when this rule is getting ran remotely, which may be causing the problem.
There are some alternative ways this rule could be laid out, but it starts to get more complicated when we do.
What I would suggest first, before attempting to rewrite your local rule differently, would be to activate this document just before we use that line of code to run it. That may eliminate the problem. If not, then we may look into rewriting that rule a bit to make it work in this situation.
So...I just slightly tweaked the earlier main code to activate that part document just before the line to run the rule.
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
Wesley Crihfield
(Not an Autodesk Employee)