Possible to run ilogic rules in a specific order?

Possible to run ilogic rules in a specific order?

alikhan.ganayev
Enthusiast Enthusiast
757 Views
5 Replies
Message 1 of 6

Possible to run ilogic rules in a specific order?

alikhan.ganayev
Enthusiast
Enthusiast

So my problem is I have created a product configuration,kind of wonky but it works as expected. The problem is that for the sake of clarity I have different rules. Pretty much all of these rules are dependant one user parameter. If this parameter is changed, a couple of components are replaced and holes are replaced by new holes. What it boils down to is that new faces are added and the new constraints are looking for faces which are not there yet unless another rule is rain first. I guess I can work around this problem in some way but it would actually be really good to know for now and the future if it's possible to run the in a specific order by perhaps creating a rule which calls on other rules? Or another  method, can't really find this topic covered anywhere.

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

theo.bot
Collaborator
Collaborator

You can run other rules from a rule. So if you supress your "design" rules and create new rule containing the order of your rules. There are standard snippets available to use:

theobot_0-1636543365256.png

 

If you suppress you rules they won't run automaticly when your change a parameter. It's not required to supress a rule, but it could avoid that a rule is fired multiple times.

 

Message 3 of 6

CattabianiI
Collaborator
Collaborator

Suppress or (better imho) check "Don't run automatically" in each rules option.

CattabianiI_0-1636550356957.png

 

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

Just checking... Are all the rules involved here 'local' rules (saved within documents), or are they all 'external' rules, or are some local, and others external?  You mentioned that some rules are being triggered to run automatically due to user parameter value change.  Are you using the Event Triggers dialog to achieve that behavior or are you just using the unquoted names of local parameters within your local rules to cause them to automatically get ran when those values of those specific parameters changes?  If you want that behavior, but just don't want it happening throughout the entire process of multiple rules running, there is actually code that can be used to stop the rules from being automatically triggered to run while you do other things, then turn the setting back on at the end if needed.

Below are just a few of these types of codes for controlling iLogic rule triggering 'on the fly':

'to start it
iLogicVb.Automation.EnterDelayedRuleRunningMode
'to check it
iLogicVb.Automation.InDelayedRuleRunningMode
'to end it
iLogicVb.Automation.ExitDelayedRuleRunningMode

'effects general rule automation stuff
'like using unquoted local parameter names in local rules
iLogicVb.Automation.RulesEnabled
'effects stuff in Event Triggers dialog
iLogicVb.Automation.RulesOnEventsEnabled

iLogicVb.Automation.GetRuleRunningOrderOption(oDoc)
oOrder = RuleRunningOrder.Browser
'oOrder = RuleRunningOrder.Legacy
iLogicVb.Automation.SetRuleRunningOrderOption(oDoc, oOrder)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6

alikhan.ganayev
Enthusiast
Enthusiast

I'm using unquoted names to get this result. I have a parameter which pretty much everything is dependent on mentioned in every rule, just always for a different purpose. I think that's causing the problem then. In what context could I use this? If I put iLogicVb.Automation.EnterDelayedRuleRunningMode at the beginning of the rule and iLogicVb.Automation.ExitDelayedRuleRunningMode at the end, would the result be the rule not getting triggered unless manually ran or by using a rule with command ilogicVb.RunRule as suggested above. Also, to what end would I need to 'check' this? This very helpful though and I do appreciate your time, it's just a tiny bit unclear.

0 Likes
Message 6 of 6

WCrihfield
Mentor
Mentor
Accepted solution

I'm not sure how you have all of your rules laid out or in what order they may be currently running, but lets say you only need that triggering action to start this whole process of running a set of other rules, but then you don't want that local rule to be triggered to run by anything that those other rules are doing, while they are doing their thing.  If that were the case, and you were going to use a single rule with several of those lines of code to run other rules, you could use the EnterDelayedRuleRunningMode just before those lines of code that run the other rules.  Then on the next line after you have ran those other rules, you could use the ExitDelayedRuleRunningMode line.  Then the local rule that usually gets triggered by the parameter change would only be fired at the very end, and only if the parameter was changed during that process.  Does that make sense to you?

I use external rules for almost everything, but I will often also have some external rules that will only run a set of other rules, then use a local rule to run that one external rule.  Using that process I almost never have to edit any code in many different documents when changes are needed, and the rules always run in the order I prefer.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes