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.

Note:

Note:

There is a discontinuity between the MAXScript Debugger window, getting variable values via Function Publishing System and evaluating the expression controller.

This means that while 'NT' might show one value in the Debugger dialog, its value in the evaluation may be different!