Thursday, March 10, 2011

Prevent iLogic Rules From Firing When Another Rule Fires

You have multiple rules set up in the same file to handle different tasks. But for some reason, when you trigger one rule (let’s call it Rule-A) it seems to trigger another rule also (we’ll call it Rule-B). In other cases, you have Rule-A set up to trigger Rule-B using the iLogicVb.RunRule function, which works fine. But for some reason Rule-A gets triggered a second time after Rule-B is run. What is causing these rules to be fired multiple times?

By default rules are run automatically when the parameters they deal with are changed. For instance, if you have a rule that sets a parameter named Length, and then the Length is changed by another rule, you might notice the first rule is being run automatically. To resolve this you can edit the rule and go to the Options tab and then select the Don’t Run Automatically option. This prevents the rule from running just because the parameter is changed, and will require the rule to be run explicitly.

Keep in mind that if you’re using the iTrigger parameter to run the rule for testing, the rule will no longer fire when the iTrigger button is clicked. This is because the iTrigger is really just a simple parameter change (incremented by one). For that reason, you might want to set up a "master" rule to handle when other rules are triggered, and have it set to run automatically, but have all of the other rules set not to run automatically.

Look for more iLogic examples on this blog or in the chapter dedicated to iLogic Basics in the next edition of Mastering Autodesk Inventor book (due out in June of 2011 if all goes well).