- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
To make the question easy to understand, let's assume the following file names:
Assembly1.iam
Assembly2.iam
EXRule1.iLogicVb
EXRule2.iLogicVb
Assembly1.iam is currently open.
While this document is active, I run the external rule EXRule1.iLogicVb.
Inside EXRule1, it opens Assembly2.iam and runs another external rule called EXRule2.
Here’s the simplified code:
Dim oDocName As String
oDocName = "C:\Temp\Assembly2.iam"
Dim openDocument As AssemblyDocument = ThisApplication.Documents.Open(oDocName, True)
openDocument.Activate()
iLogicVb.RunExternalRule("EXRule2")The Problem:
In EXRule2.iLogicVb, when I try to access parameters or properties using ThisDoc,
it still points to Assembly1.iam, not the newly opened Assembly2.iam.
However, all logic inside EXRule2 is written assuming that the current document is Assembly2.iam,
so most parameter calls are like this:
Parameter("MyParam")If I use ThisApplication.ActiveDocument instead, then I'd need to rewrite all parameter calls like:
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim myParam As String = oDoc.ComponentDefinition.Parameters("MyParam").ValueBut the problem is, there are hundreds of parameters used in EXRule2, and rewriting all of them is not realistic.
Is there any way to make the newly opened Assembly2.iam be recognized as ThisDoc in EXRule2?
Or any workaround that allows me to keep using short form like Parameter("MyParam") inside the rule
as if Assembly2.iam is the current document?
Any ideas or best practices would be greatly appreciated.
Thank you!
Solved! Go to Solution.