Create global expressions

You can use global expressions to set multiple attributes with the same computed value.

For example, you can use a global expression to create random values for overall primitive size. This way, the attributes, such as Length, Width, and Depth, use the same random values to maintain the primitive's proper shape.

Global expressions provide an ideal way to compute constant values for other attribute-based expressions. They are Collection-based so they can be applied to all Descriptions belonging to a Collection.

If you are new to using XGen expressions, see XGen expression basics.

To create a global randomization expression

  1. In the XGen Editor, click the Expressions tab.
  2. Type a Name for the expression, such as randomize.
  3. Click the + and beside randomize.

    Maya creates an empty ( value =0) global expression.

  4. Click this icon to open the XGen Expression Editor.
  5. In the bottom pane, create the first line in expressing by typing $a=;.

    This creates a slider control for the expression's input value.

  6. In the second line of the expression, add a randomization function by typing $a * rand(0.5 3.0).
  7. Click Accept.

    Maya adds the randomize expression to the Expression tab.

  8. In the Expression tab, use the slider control to set the expression's input value.
  9. To control attributes using the randomization expression, type the expression name followed by () beside the attributes.

    For example, type randomize() beside Length, Width, and Depth to randomize the size of generated primitives.