User guide
172
# Get root level
root = NodegraphAP.GetRootNode()
# Create a PrimitiveCreate node at root level
prim = NodegraphAPI.CreateNode( 'PrimitiveCreate', root )
# Get the root parameter of the PrimitiveCreate node
rootParam = prim.getParameters()
# Add a new User Parameter of type string
stringParam = rootParam.createChildString( "yourFilePath", "yourFile.txt" )
# Tell Katana to use the assetIdInput widget to represent this parameter
stringParam.setHintString( "{'widget': 'assetIdInput'}" )
Or, to add a User Parameter of type string, as a drop-down menu:
# Get root level
root = NodegraphAP.GetRootNode()
# Create a PrimitiveCreate node at root level
prim = NodegraphAPI.CreateNode( 'PrimitiveCreate', root )
# Get the root parameter of the PrimitiveCreate node
rootParam = prim.getParameters()
# Add a new User Parameter of type string
stringParam = rootParam.createChildString( "yourDropdown", "yourDefaultValue" )
# Tell Katana to use the pop-up widget
# and fill out the menu values
stringParam.setHintString( "{'widget':'popup',\
'options':[ 'a', 'b', 'c' ]}" )
See Widget Types for a table of the widget types seen in the UI.
Parameter Expressions
Python
A parameter can have its value computed dynamically using a Python expression. Expressions are set using
Parameter.setExpression(), which takes a Python string representing the expression as its first argument and an
optional enable parameter to specify whether to implicitly enable the expression.
A parameter expression must evaluate in the same way that a Python eval expression would (as a condition list). The
global and local scopes of a parameter expression are sand-boxed so that it is not possible to make topological
changes to the Node Graph whilst it is being resolved.
23 NODEGRAPH API | PARAMETER EXPRESSIONS