Control primitives using expressions

Use expressions to generate values for primitive attributes and XGen modifiers. For example, you can create an expression that randomizes values for primitive length or adds noise to Clumping modifier values.

Expressions can be used locally to modify single attribute values and they can be used globally to apply to all Descriptions in a Collection ( see Create XGen global expressions). Attributes that are controllable using an expression are identified by this icon: .

Use expressions to control primitives by:

Create an expression to control an attribute or modifier

  1. In the XGen Editor, click the icon beside the attribute or modifier setting you want to modify.
  2. In the XGen Expression Editor, type your expression in the edit area.
  3. To execute the expression click Accept.

    XGen updates the Description preview and closes the XGen Expression Editor.

Load an expression

You can load a saved expression or a pre-authored sample XGen expression that comes with Maya.

To load an expression from the XGen Expression Editor

  1. Click the Library or Samples tab, and then browse to the expression you want to load.

    The Library tab lists user-defined expressions saved to your xgen/library directory. The Samples tab lists pre-authored sample XGen expressions that come with Maya.

  2. Select an expression from the list.

    The expression loads in the edit area of the XGen Expression Editor.

  3. To execute the expression, click Accept.

    If the Description does not update, ensure that Update Description Automatically is on.

To load an expression from the XGen Editor

  1. Click the icon beside the primitive or modifier attribute you want set with an expression.
  2. Select Load Expression, and then choose from the following:
    • library to browse for user-defined expressions saved in your XGen library directory.
    • samples to browse for pre-authored XGen expressions that come with Maya.
    • Load other to browse for expressions saved in other locations.
    Note: Any global expressions created in your Description also appear in the list.
  3. Select the expression to execute it.

Save an expression

After you create or modify an expression, you can save it as an SeExpr (.se) expression file. By default, expressions are saved to the Library tab of the XGen Expression Editor, which is sourced from one of the following directories:

You can load these expressions for use at another time.

To save an expression from the XGen Expression Editor

  1. Click the Save or Save As, and if necessary, browse to the you to save the expression.

To save an expression from the XGen Editor

  1. Click the icon beside the primitive or modifier attribute that uses the expression you want to save, and select Save Expression As.
  2. If necessary, browse to the directory you want to save the expression to.