User guide
173
It is possible to write an expression that will reference a node by name and not break when the node name changes,
see Appendix B: Expressions In the Katana User Guide for more information and a list of what functions are available
to an expression.
NOTE: you should avoid using the nodeName variable for parameter expressions that specify scene graph
locations, and must take care when using them anywhere that a scenegraph attribute is set. Node names
are not namespaced and can therefore change unpredictably.
The following example script sets the expression on a parameter:
# Add a PrimitiveCreate node
root = NodegraphAPI.GetRootNode()
primitive = NodegraphAPI.CreateNode( 'PrimitiveCreate', root )
# Add a User Parameter of type Number, called myNumber
rootParam = primitive.getParameters()
rootParam.createChildNumber( "myNumber", 7.0 )
# Link myNumber to the node's scale x parameter by expression
scaleX = NodegraphAPI.GetNode( 'PrimitiveCreate' )\
.getParameter( 'transform.scale.x' )
scaleX.setExpression( "getParam( 'PrimitiveCreate.myNumber' )" )
You can disable an expression with the setExpressionFlag() method.
yourExpression.setExpressionFlag( False ) # Disable
yourExpression.setExpressionFlag( True ) # Enable
CEL
Parameters that contain CEL expressions are set like any other string parameter only the value of the parameter is
evaluated to a CEL expression. For example create a CEL expression on a CollectionCreate node that sets to the
/root/geo location:
TIME = 0
root = NodegraphAPI.GetRootNode()
collection = NodegraphAPI.CreateNode( 'CollectionCreate',\
root)
c = collection.getParameter( 'CEL' )
c.setValue( "( (/root/geo) )", TIME )
For more on CEL, and collections using CEL, see the Collections & CEL chapter in the Katana User Guide.
23 NODEGRAPH API | CEL