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:
- Creating new expressions in the
XGen Expression Editor.
- Loading a pre-authored sample XGen expression that comes with Maya.
- Loading an expression that was previously created, and then saved to the XGen
Library
.
Create an expression to control an attribute or modifier
- In the
XGen Editor, click the
icon beside the attribute or modifier setting you want to modify.
- In the
XGen Expression Editor, type your expression in the edit area.
- 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
- 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.
- Select an expression from the list.
The expression loads in the edit area of the
XGen Expression Editor.
- 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
- Click the
icon beside the primitive or modifier attribute you want set with an expression.
- 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.
- 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:
-
C:/Users/<username>/Documents/xgen/expressions
-
${HOME}/xgen/expressions
You can load these expressions for use at another time.
To save an expression from the XGen Expression Editor
- 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
- Click the
icon beside the primitive or modifier attribute that uses the expression you want to save, and select
Save Expression As.
- If necessary, browse to the directory you want to save the expression to.