Hi There,
I have a part which contains a large iLogic rule. The rule is triggered from 5 parameter which are contained in a seperate part and derived through.
Sometimes all five of these trigger parameters change at once. My problem is that this causes the ilogic rule to run 5 times which is annoying, and time consuming. Is there a way to make the rule run just once (the rule is quite slow in running).
I have attached two sample parts to demonstrate what I mean. Part1.ipt contains a rule called 'trigger' which runs another rule called 'master'. The rule trigger contains the parameters so that it runs when they change. Part2.ipt has the parameters set as user parameters.
If I change three of the parameters the rule runs three times, four parameters, four times, etc etc. So I want the rule to run just once if all parameters change at once or just one parameter changes.
Any ideas?
thanks,
John
Solved! Go to Solution.
Solved by LukeDavenport. Go to Solution.
Hi Johnster100,
There may well be an easier way than this but it works fine for me.
Try the following:
1) Set the trigger rule to 'Don't Run Automatically' (in the options tab)
2) Make sure the linked parameters are actually used in MODEL parameters (not just as USER parameters). This will then enable you to set an iLogic event trigger on 'Any Model Parameter Change' for the 'Trigger' rule. You'll have to create some lines in a dummy sketch and apply param1 etc as the lengths of the lines. Then turn the sketch visibility off and forget about it.
3) Create a user parameter called Sum_Of_Linked_Params (doesn't matter what value is assigned)
4) The trigger rule will still be running 4 times if 4 parameters are changed. But now you can change it to the following:
x1 = param1
x2 = param2
x3 = param3
x4 = param4
x5 = param5
' Check to see if the sum of all the linked parameters has changed
If Not x1 + x2 + x3 + x4 + x5 = Sum_Of_Linked_Params Then
iLogicVb.RunRule("Master")
End If
' Set 'Sum' parameter again for next time
Parameter("Sum_Of_Linked_Params") = x1 + x2 + x3 + x4 + x5
InventorVb.DocumentUpdate()
This works fine for me - the master rule now only gets triggered once no matter how many parameters change.
Luke
Of course the above won't work if the parameters are changed but the sum of all of them happens to remain the same!
It'd be nice to improve the above method by looping through all the linked parameters to get the sum of them rather than explicitly typing in each parameter. But I don't have time to do that right now.
Luke