RunRule in another component (opened invisible)

RunRule in another component (opened invisible)

marcin_bargiel
Advocate Advocate
380 Views
2 Replies
Message 1 of 3

RunRule in another component (opened invisible)

marcin_bargiel
Advocate
Advocate
Dim oModel As Document
Dim auto = iLogicVb.Automation
oModel = ThisApplication.Documents.Open("f:\newPart.iam", True)
auto.RunRule(oModel, "UPDATE angles")

 

Above code works great when component is opened in Visible Mode.

When i change opening to invisible

oModel = ThisApplication.Documents.Open("f:\newPart.iam", False)

my rule does not RUN, why? is it possible to run in Invisible Mode ?

 

Vote for REPLACE VARIES !
REPLACE VARIES
0 Likes
Accepted solutions (1)
381 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Hi @marcin_bargiel.  Good question.  When you say that the rule does not run, are you absolutely sure about that?  Are there any error messages?  If so, what do they say (on both tabs)?  If not, try putting a MsgBox(1) or MessageBox.Show(1) in it that will always show when the rule is ran, then try it again.  If you see those messages, you know the rule is running, but maybe just not targeting the right document.  If I am remembering correctly, when you open a document 'visibly' it will become the 'active' document, but when you open a document 'invisibly' it may not become the 'active' document.  So, if your rule is 'targeting' the 'active' document, it may not be working with the correct document when it runs.  If your rule is using ThisApplication.ActiveDocument to define which document it is targeting, then you may have to change that to ThisDoc.Document, so that it will be targeting the 'local' document instead (Link1).  Also, there are several iLogic snippets which will automatically target the 'active' document by default, unless you specify a different document for it to look at.  Those may be trying to work with the wrong document too.  You may have to replace them with the equivalent API code, instead of using the iLogic snippet shortcut codes.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

marcin_bargiel
Advocate
Advocate
Accepted solution

Adding those two lines solved my problem

	oModel.Update2
	oModel.Save

Before i used only 

oModel.Close

that's why i thought the rule does not run...

Vote for REPLACE VARIES !
REPLACE VARIES
0 Likes