User guide

161
Ports can be added by index as well as by name which allows direct control of their ordering. For example, to add an
input port to the merge node created above, add the following:
betweenFirstAndSecondPort =\
merge.addInputPortAtIndex( "BetweenFirstAndSecond", 1 )
Connecting Ports
The connect() method links ports. For example, to take an output port on a PrimitiveCreate node - referenced as
node - and connect it to an input port on a Merge node - referenced as merge - enter the following:
primitiveOut = node.getOutputPort( "out" )
mergeInput = merge.getInputPort( "i0" )
primitiveOut.connect( mergeInput )
Connecting ports works in either direction:
mergeInput.connect( primitiveOut )
Disconnecting Ports
The disconnect() method unlinks two ports. For example, to unlink the two ports connected in Connecting Ports
enter the following:
mergeInput.disconnect( primitiveOut )
or
primitiveOut.disconnect( mergeInput )
Renaming Ports
The renameInputPort() and renameOutputPort() methods rename ports. For example, to rename the input port
at index position 0 on the node referenced by merge, enter the following:
merge.renameInputPort( "i0", "input" )
To rename the output port on the same node, enter:
merge.renameOutputPort( "out", "output" )
Duplicating Nodes
Serialize to XML
Katana uses a copy and paste pattern to duplicate nodegraph nodes, which means that to copy a node you must
serialize it to XML using BuildNodesXmlIO(), then deserialize. For example, to create then serialize a PrimitiveCreate
23 NODEGRAPH API | DUPLICATING NODES