Expression Controllers
The Expression controllers in 3ds Max 8 and higher have been completely exposed to MAXScript via the IExprCtrl interface documented below.
In versions prior to 3ds Max 8, there were no properties or methods accessible for Expression controllers.
The following Expression controllers are available:
Float_Expression : FloatController
Point3_Expression : Point3Controller
Position_Expression : PositionController
Scale_Expression : ScaleController
Properties:
<expression_controller>.ThrowOnError Bool default:true
Controls whether to throw when an error occurs in the expression.
Interfaces:
All expression controllers expose the IExprCtrl Interface since 3ds Max 8 . This interface provides all methods to access the controller through MAXScript:
IExprCtrl - Expression Controller Interface
Methods:
<boolean>SetExpression <string>Expression
Sets the expression string to the string passed by-reference. Returns true on success, false otherwise.
<string>GetExpression()
Returns the expression string.
<integer>NumScalars ()
Returns the number of scalars defined in the controller.
<integer>NumVectors ()
Returns the number of vectors defined in the controller.
<boolean>AddScalarTarget <string>Name <value>Target Offset:<time> Owner:<maxObject>
Offset default value: 0f
Owner default value: undefined
Adds a scalar target. The first argument is the name of the scalar. The second argument is the target to be connected to the scalar.
<boolean>AddVectorTarget <string>Name <value>Target Offset:<time> Owner:<maxObject>
Offset default value: 0f
Owner default value: undefined
Adds a vector target. The first argument is the name of the vector. The second argument is the target to be connected to the vector.
<boolean>AddVectorNode <string>Name <node>Node Offset:<time>
Offset default value: 0f
Adds a vector node. The first argument is the name of the vector. The second argument is the node to be connected to the vector.
<boolean>AddScalarConstant <string>Name <float>Constant
Adds a scalar constant. The first argument is the name of the scalar. The second argument is the constant value to be assigned to the scalar.
<boolean>AddVectorConstant <string>Name <point3>Constant
Adds a vector constant. The first argument is the name of the vector. The second argument is the constant value to be assigned to the vector.
<boolean>SetScalarTarget <value>Which <value>Target Owner:<maxObject>
Owner default value: undefined
Sets the target of the given scalar variable. Returns true on success, false otherwise. The optional Owner parameter can be supplied to specify the owner of the target track in case the target is instanced across multiple objects.
<boolean>SetVectorTarget <value>Which <value>Target Owner:<maxObject>
Owner default value: undefined
Sets the target of the given vector variable. Returns true on success, false otherwise. The optional Owner parameter can be supplied to specify the owner of the target track in case the target is instanced across multiple objects.
<boolean>SetVectorNode <value>Which <node>Node
Sets the node of the given vector variable. Returns true on success, false otherwise.
<boolean>SetScalarConstant <value>Which <float>Constant
Sets the value of the given scalar variable to the specified constant value. Returns true on success, false otherwise.
<boolean>SetVectorConstant <value>Which <point3>Constant
Sets the value of the given vector variable to the specified constant value. Returns true on success, false otherwise.
<boolean>DeleteVariable <string>Name
Deletes the variable with the given name. Returns true on success, false otherwise.
<string>GetDescription()
Returns the description string of the controller.
<boolean>SetDescription <string>Description
Sets the description string of the controller to the specified by-reference string argument.
<time>GetOffset <string>Name
Returns the offset of the given variable.
<boolean>SetOffset <string>Name <time>Offset
Sets the offset of the given variable to the specified time value.
<void>Update ()
Updates the controller.
<boolean>VariableExists <string>Name
Returns true if the named variable exists, false otherwise.
<float>GetScalarConstant <value>Which
Returns the value of the given scalar constant.
<value>GetScalarTarget <value>Which asController:<boolean>
asController default value: false
Returns the target of the given scalar variable. If the optional asController parameter is set to true, the result will be a controller value.
<point3 by value>GetVectorConstant <value>Which
Returns the value of the given vector constant.
<value>GetVectorTarget <value>Which asController:<boolean>
asController default value: false
Returns the target of the given vector variable. If the optional asController parameter is set to true, the result will be a controller value.
<node>GetVectorNode <value>Which
Returns the node of the given vector variable.
<float>GetScalarValue <value>Which
Returns the value of the given scalar variable.
<point3 by value>GetVectorValue <value>Which
Returns the value of the given vector variable.
<value>GetValue <string>Name
Returns the value of the named variable.
<enum>GetScalarType <value>Which
GetScalarType enums: {#unknown | #scalarTarget | #scalarConstant | #vectorTarget | #vectorConstant | #vectorNode}
Returns the type of the given scalar variable.
<enum>GetVectorType <value>Which
GetVectorType enums: {#unknown | #scalarTarget | #scalarConstant | #vectorTarget | #vectorConstant | #vectorNode}
Returns the type of the given vector variable.
<enum>GetValueType <string>Name
GetValueType enums: {#unknown | #scalarTarget | #scalarConstant | #vectorTarget | #vectorConstant | #vectorNode}
Returns the value type of the given variable.
<string>GetScalarName <index>Index
Returns the name of the indexed scalar variable.
<string>GetVectorName <index>Index
Returns the name of the indexed vector variable.
<index>GetScalarIndex <string>Name
Returns the index of the named scalar variable.
<index>GetVectorIndex <string>Name
Returns the index of the named vector variable.
<string>PrintDetails ()
Prints information about the expression controller, including description string, expression code, scalars and vectors details.
- To change the existing value for a variable, you can also use the appropriate
AddScalarTarget(),
AddVectorTarget(),
AddVectorNode(),
AddScalarConstant(),
orAddVectorConstant().
Using these methods will also set the offset value. - You cannot change the type of a variable (Scalar/Vector) - you must remove the variable and add it as the new type.
- The
<value> Target
argument toAddScalarTarget(),
AddVectorTarget()
andAddVectorNode()
can be either a controller or a subAnim value. If it is a controller, the methods will look for the controller under the specified Owner value if supplied, otherwise it will use the first owner found. - For methods that take an argument of
<value>Which
, the value of Which can be either an integer index or a string name, - Expression controller variable names are case sensitive!.
- All Function Publishing System operations support undo/redo.
- The expression controller’s expression is only evaluated by calling
SetExpression()
andUpdate()
.
There is a discontinuity between the MAXScript Debugger window, getting variable values via Function Publishing System and evaluating the expression controller.
- When working with the Debugger dialog, variable values are shown based on the current slider time.
- When accessed via Function Publishing System, the variable values returned are based on the current MXS time.
- When evaluating the controller, the result is based on the current time value, but also the range of the controller, the Out-Of-Range Type set for the controller, and any Ease curves applied to the controller.
This means that while 'NT' might show one value in the Debugger dialog, its value in the evaluation may be different!