SetExpr

Description

Adds or modifies an expression on a parameter without opening the Expression Editor. If you want to open the Expression Editor during execution, use the AddExpr command instead.

An expression is a string of characters that may include object and parameter names, mathematical operators, and tokens representing functions or constants. For example, to constrain object A's Y rotation to object B's X translation, you would set an expression on A.kine.local.roty consisting of the string B.kine.local.posx.

An expression is a mathematical formula that you can use to control any parameter that can be animated, such as translation, rotation, scaling, material, or texture. You can create almost any connection you like between parameters, from simple "A = B" relationships to very complex ones using predefined variables, standard math functions, random number generators, and more.

For more information on expressions, see the Animation guide.

Note: This command uses output arguments. C# and some scripting languages (such as JScript, PerlScript and Python) don't support arguments passed by reference so you need to use the best workaround for your situation:

For scripting languages this command returns an ISIVTCollection which you can use to get the output arguments.

For C# you can use the XSIApplication.ExecuteCommand method to call this command. ExecuteCommand packs the output arguments into a C# System.Object containing an Array of the output arguments (see Calling Commands from C#).

Scripting Syntax

SetExpr( [InputObj], [ExprStr], [ExprObj] );

Parameters

Parameter Type Description
InputObj String List of parameters (for example "cone*/kine.local.pos").

Default Value: Currently selected and marked parameters

ExprStr String An expression.

Default Value: Current parameter value (for example, "a.kine.global.posx = 3.5")

ExprObj XSICollection Returns a list of expression objects

Examples

VBScript Example

'

' This example sets an expression on a parameter using the SetExpr 

' command and then uses the EditExpr command to open the Expression 

' Editor to inspect the new expression.

'

' Create the object on which to set the expression

set oDonut = CreatePrim( "Torus", "NurbsSurface" )

' Make sure the last frame will be set to 100

SetValue "PlayControl.Out", 100

' Set a key frame at frame 1, with XPos = -30

SaveKey oDonut & ".kine.local.posx", 1, -30

' Set another key frame at frame 100, with XPos = 30

SaveKey oDonut & ".kine.local.posx", 100, 30

' Animate the YPos parameter with an expression 

SetExpr oDonut & ".kine.local.posy", _

		"5*sin(" & oDonut & ".kine.local.posx * 15)"

' Now display the Expression Editor to see the results

EditExpr oDonut & ".kine.local.posy"

See Also

Parameter.AddExpression EditExpr RemoveAnimation RemoveAllAnimation AddExpr