If your expression has redundant statement calculations, you can turn off Always Evaluate to speed up scrubbing and playback of your animation. To understand when this feature is useful, you must understand the subtle details of expression execution.
An expression generally executes whenever the animation time changes. An expression also executes whenever an attribute that’s read by the expression changes value, and either of the following two actions occurs:
In this context, the predefined variables time and frame are also considered attributes the expression reads.
Suppose you write an expression that moves a NURBS sphere along the Y-axis at twice the current value of its X-axis translation:
nurbsSphere1.translateY = 2 * nurbsSphere1.translateX;
If you use the Move tool in the workspace to drag the sphere in an X-axis direction, Maya executes the expression for each incremental change to the translateX attribute as you drag.
Dragging the sphere in the X direction changes the value of the translateX attribute in the expression. As you drag the sphere and Maya updates the workspace display, the value of the translateY attribute changes in the expression. This makes the expression execute.
If you turn Always Evaluate off, an expression won’t execute if it contains only print function statements, variable assignments, or assignments that do not read attribute values.
global float $BallHeight = 5; print($BallHeight+"\n"); nurbsSphere1.tx = rand(1); print(nurbsSphere1.tx+"\n");
The first statement declares and assigns a value to the variable $BallHeight, which is not an attribute. The next statement prints the $BallHeight but assigns no value to an attribute.
The next statement assigns an attribute a value, but the value is generated by the random number function rand. This function doesn’t read an attribute value. For details on the rand function, see rand.
The last statement reads and prints the value of an attribute, but doesn’t assign a value to an attribute.
None of these actions causes the expression to execute when Always Evaluate is off.
Always Evaluate affects only the expression you’re creating or editing. You can turn it on for one expression and off for another.
For most animations, expressions execute regardless of whether Always Evaluate is on. If in doubt, leave it on.