Object Hierarchy | Related C++ Class: Expression
Expression
v2.0
An Expression object is a kind of Operator representing an animation source on a
parameter which you can create with Parameter.AddExpression.
Expressions in Softimage allow you to control animatable parameters
through a mathematical formula, which may include references to the
value of other parameters. This formula is stored as the value of
the "Definition" Parameter, and it can be changed via the Object
Model as shown in the example below.
If a Parameter's value is driven by an Expression then the
Expression can be retrieved via the Parameter.Source property.
Since the expression object is kind of operator, you can use the
Operator.InputPorts property
to access the parameters from which the expression is reading.
Access to port groups is also provided (since this is a kind of
operator); however, the expression doesn't define port groups but
will pretend it has one for easy access through the SDK (see
Operator.GetNumPortGroups for
more details).
For more details, see "Expression Reference" in the Softimage
User?s Guide.
// This example illustrates how to apply an expression and access it. NewScene( null, false ); var oNull = ActiveSceneRoot.AddNull(); var oAnotherNull = ActiveSceneRoot.AddNull("AnotherNull"); strExpr = oAnotherNull.posy.FullName + " + 2"; var oExpr = oNull.posx.AddExpression(strExpr); //You can access the parameter to which an expression is connected by using the output port. Application.LogMessage("Parameter owner of the expression " + oExpr.OutputPorts(0).Target2.FullName); //You can access the parameter which are used inside an expression by using the input ports of //the expression operator. var oInputPorts = oExpr.InputPorts for(i = 0; i < oInputPorts.Count; i++) { Application.LogMessage("Parameter client of the expression " + oInputPorts(i).Target2.FullName); } // Formula that defines the expression is available as a Parameter value oDefinitionParam = oExpr.Parameters( "Definition" ) Application.LogMessage( "Expression definition :" + oDefinitionParam.Value) ; // Expression can be changed strNewExpr = oAnotherNull .posy.FullName + " - " + oAnotherNull .posx.FullName ; oDefinitionParam.Value = strNewExpr ; Application.LogMessage( "New expression definition : " + oDefinitionParam.Value ) ; // Show the new expression formula in action oAnotherNull.posy = 10 ; oAnotherNull.posx = 4 ; // Value should be 10 - 4 = 6 Application.LogMessage( "With new expression posx is " + oNull.posx.value ) ; // Remove the expression oNull.posx.Disconnect() ; //INFO : Parameter owner of the expression null.kine.local.posx //INFO : Parameter client of the expression AnotherNull.kine.local.posy //INFO : Expression definition :AnotherNull.kine.local.posy + 2 //INFO : New expression definition : AnotherNull.kine.local.posy - AnotherNull.kine.local.posx //INFO : With new expression posx is 6 |