Referencing Rule-Running Document

Referencing Rule-Running Document

Anonymous
Not applicable
486 Views
4 Replies
Message 1 of 5

Referencing Rule-Running Document

Anonymous
Not applicable

Hi,

 

I'm just trying to understand how to reference the document running a rule invoked by another via `iLogicVb.Automation.RunExternalRule()` when that document was opened silently.

 

How/is this possible?

 

Thanks

 

[Added the wrong tags to this one by mistake, but maybe it's closely enough related]

0 Likes
Accepted solutions (1)
487 Views
4 Replies
Replies (4)
Message 2 of 5

Michael.Navara
Advisor
Advisor

If I understand well

  • you run rule in TopDocument
  • From this rule you call RunExternalRule on SubDocument
  • During execution of rule in SubDocument you need a reference to TopDocument

In this case use something like this

Dim map As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
map.Add("TopDocument", ThisDoc)
iLogicVb.RunExternalRule("ruleName", map)
Message 3 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Hi @Anonymous.  The online help link for that version of the RunExternalRule method, which is under the Automation object, is here:

IiLogicAutomation.RunExternalRule Method 

This version of that method actually allows you to supply a document object as the first input variable, then the name of the external rule as the second input variable.  That first document object that you input is supposed to act as "the context in which rule is run", which means, that is the document that you want the rule to act upon.  However, if your external rule is getting the 'target' document it is supposed to act upon using the term ThisApplication.ActiveDocument, this will often cause this behavior to fail.  In cases like this, you would be better using the term ThisDoc.Document within that external rule to point to which document for it to target.  That term will work together with this method's intent.  Then if you wanted to be extra sure you are targeting the right document, you could also use the RunExternalRuleWithArguments version of that method, and put the document you want the rule to target within the 'arguments' (a NameValueMap), that you supply as the third input variable.  But if you use the NameValueMap route, then the external rule needs to be prepared to receive those 'arguments', so it can use them.  That is done using the RuleArguments interface.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 5

Anonymous
Not applicable
Yes, that's exactly what I was looking for. I had no idea about `ThisDoc.Document`. Thanks
0 Likes
Message 5 of 5

Anonymous
Not applicable

Thanks for the response. This isn't what I was looking for, but I appreciate you taking the time. The other person had the right interpretation for my poorly phrased question!

0 Likes