iLogic variable not up-to-date

When an iLogic rule runs and it has a variable with the name of a given Inventor parameter, then it will take the current value of that parameter and keep using it – its value will not get updated if the value of the parameter is changed in the meantime outside the rule.
The following article alludes to it, though does not say it explicitly: About Rules and Forms in iLogic

Let’s say we have a parameter named “MyParam” and two rules: “MyRule” and “ChangeMyParam“. Neither rule is run automatically, i.e. they have the “Don’t run automatically” option checked:

DontRunAutomatically

Inside “MyRule” we use “MyParam” variable and show its value before and after calling “ChangeMyParam” rule.

MyRule:

MessageBox.Show(MyParam, "MyRule before ChangeMyParam")
iLogicVb.RunRule("ChangeMyParam")
MessageBox.Show(MyParam, "MyRule after ChangeMyParam")
MessageBox.Show(Parameter("MyParam"), "MyRule after ChangeMyParam")

ChangeMyParam:

MyParam = MyParam + 10

This is what we get when we run “MyRule“:

MyRule

As you can see, if you want to get the up-to-date value of an Inventor parameter, then you can use the Parameter() function.

-Adam


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading