Call iLogic rule from add-in

Call iLogic rule from add-in

gmetcalfe
Contributor Contributor
1,849 Views
5 Replies
Message 1 of 6

Call iLogic rule from add-in

gmetcalfe
Contributor
Contributor

Is there a way to directly call an iLogic rule from within an add-in?

 

I have written an add-in that manipulates parameters in various sub-assemblies and now need to call various iLogic rules which the designers have written to act on the parameter changes.

 

ta

 

Gav

0 Likes
Accepted solutions (1)
1,850 Views
5 Replies
Replies (5)
Message 2 of 6

MjDeck
Autodesk
Autodesk

The rules should run automatically when the parameters change.  Is that not working the way you expect?  If so, it is possible to run rules explicitly from an add-in.  Is your add-in in VB.NET or C#?  What version of Inventor?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 3 of 6

gmetcalfe
Contributor
Contributor

Sorry we are running 2011 (although I am testing in 2011 & 2012) and the add-in is written in c#. So far the rules are not running automatically but I would like more control and call the rules directly if possible anyway. Longer term the "Don't run automatically" will be set in all the rules.

 

thanks

 

Gav

0 Likes
Message 4 of 6

rjay75
Collaborator
Collaborator

Here's the way I've run rules using C#

 

//For Rules in documents
int rVal = 0;
iLogicRule iRule = iLogicAutomationObject.GetRule(IVDocument, ruleName);
if (iRule != null) { rVal = iLogicAutomationObject.RunRuleDirect(iRule);

//For external rules
int rVal = 0;
rVal = iLogicAutomationObject.RunExternalRule(IVDocument, ruleName);

 

Message 5 of 6

MjDeck
Autodesk
Autodesk
Accepted solution

Here's a sample C# class that links to the automation interface in the iLogic addin, and has functions to run rules.   A disadvantage of this direct linking method is that you need separate versions of your addin for Inventor 2011 and 2012.

 If you don't want separate versions, you can use COM late binding instead.  That requires more (and messier) code.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 6 of 6

gmetcalfe
Contributor
Contributor

Perfect. Thanks very much.

0 Likes