iLogic Run External rule has no option to run in another component?

iLogic Run External rule has no option to run in another component?

pball
Mentor Mentor
1,002 Views
3 Replies
Message 1 of 4

iLogic Run External rule has no option to run in another component?

pball
Mentor
Mentor

I'm trying to run an external iLogic rule on a model from inside the drawing of that model. I found a few threads with references to iLogicVB.RunExternalRule that reference the part and external rule. This thread here shows what I want to do, but trying to call out a component in that command throws an error.

 

Using the new handy iLogic editor, the RunExternalRule command doesn't list the option for supplying a component to run the rule on. Did this get removed in recent versions? I'm currently using 2020.2.1.

 

image.png

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Accepted solutions (1)
1,003 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @pball 

 

I'm not sure if something changed or not, but this does work in Inventor 2020:

 

iLogicVb.Automation.RunExternalRule(oDoc, "MyRule")

 

 

You can use something like this to open the document so that the external rule will "see" it

 

oDoc = ThisDrawing.ModelDocument

Dim openedView As Inventor.View = Nothing
If oDoc IsNot ThisApplication.ActiveDocument Then
	openedView = oDoc.Views.Add()
	oDoc.Activate()
End If

'optional, hide openedView afer it opens
'openedView.Visible = False 

iLogicVb.Automation.RunExternalRule(oDoc, "MyRule")

If openedView IsNot Nothing Then
	openedView.Close()
End If 

 

'example external rule
"MyRule"

MessageBox.Show(ThisApplication.ActiveDocument.fullfilename, "iLogic")

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

EESignature

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor

You would just have to activate whichever document you want the external rule to work on, before you run the external rule.  This can easily be done by code.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

pball
Mentor
Mentor

@Curtis_Waguespack  Adding the Automation in there is exactly what I needed. Interesting the shorter version doesn't work.

 

@WCrihfield  I knew that was an option but for this script I want things to be seamless.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes