User guide
160
print ( node.getParameters().getXML() )
Which displays the XML of the selected node:
<group_parameter name="PrimitiveCreate">
<string_parameter name="name" value="/root/world/geo/primitive"/>
<string_parameter name="type" value="sphere"/>
...
</group_parameter name>
Getting Parameter Values
To return the value of a parameter, use getParameter().getValue(). For example, to return the value of the name
parameter at time 0, enter the following:
node.getParameter( 'name' ).getValue( 0 )
Setting the Parameters of a Node
Values on a node are set using getParameter().setValue(). As node behavior is set by parameters who’s values can
change over time, you must specify a value and a time, when setting a parameter.
For example, to change the type Parameter of a PrimitiveCreate node to teapot, when time is 10, enter the following:
# Get the root node
root = NodegraphAPI.GetRootNode()
# Create a new node at root level
node = NodegraphAPI.CreateNode('PrimitiveCreate', root)
# Set the type parameter at time 10
node.getParameter('type').setValue( "teapot", 10 )
Input and Output Ports
Creating Ports
Katana recipes are created by adding and connecting nodes in the Node Graph. Nodes are connected through their
input and output ports. Some node types have a fixed number of ports, while others allow for an arbitrary number.
The Merge node, for example, takes any number of inputs and combines them into a single output. To create a
Merge node referenced as merge at root level, and add two input ports enter the following:
merge = NodegraphAPI.CreateNode( 'Merge', root )
firstPort = merge.addInputPort( "First" )
secondPort = merge.addInputPort( "Second" )
23 NODEGRAPH API |