Inventor Customization

Inventor Customization

Reply
Contributor
gmetcalfe
Posts: 17
Registered: ‎08-11-2010
Message 1 of 6 (526 Views)
Accepted Solution

Call iLogic rule from add-in

526 Views, 5 Replies
06-29-2011 05:20 AM

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

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.

 

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 2 of 6 (522 Views)

Re: Call iLogic rule from add-in

06-29-2011 10:31 AM in reply to: gmetcalfe

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
DLS - Mechanical Design
Autodesk, Inc.

Contributor
gmetcalfe
Posts: 17
Registered: ‎08-11-2010
Message 3 of 6 (517 Views)

Re: Call iLogic rule from add-in

06-30-2011 12:39 AM in reply to: MjDeck

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

Valued Mentor
rjay75
Posts: 362
Registered: ‎04-14-2005
Message 4 of 6 (498 Views)

Re: Call iLogic rule from add-in

06-30-2011 07:31 AM in reply to: gmetcalfe

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);

 

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 5 of 6 (494 Views)

Re: Call iLogic rule from add-in

06-30-2011 07:55 AM in reply to: gmetcalfe

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
DLS - Mechanical Design
Autodesk, Inc.

Contributor
gmetcalfe
Posts: 17
Registered: ‎08-11-2010
Message 6 of 6 (492 Views)

Re: Call iLogic rule from add-in

06-30-2011 08:08 AM in reply to: gmetcalfe

Perfect. Thanks very much.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.