User guide
166
# Connect PrimitiveCreate output to Merge input
# Get the out port of the PrimitiveCreate node
primitiveOut = primitive.getOutputPort( "out" )
mergeSphereIn = mergeOne.addInputPort( 'sphere' )
primitiveOut.connect( mergeSphereIn )
# Get the groups Return port
# First create an output port on the group
groupOut = group.addOutputPort( "goingOut" )
groupReturn = group.getReturnPort( "goingOut" )
# Get the output port on the Merge node
mergeOut = mergeOne.getOutputPort( "out" )
# Connect the Merge node's out to the Group node's Return
mergeOut.connect( groupReturn )
Now you can connect the output of the Group node to external nodes without accessing its internal structure. For
example, take the example above, and connect the output of the Group node to a new Merge node:
# Create a Merge node at root level
mergeTwo = NodegraphAPI.CreateNode( 'Merge', root )
# Get the input port of the Merge node
mergeTwoInput = mergeTwo.getInputPort( 'input' )
# Connect the Group’s output to the Merge node's input
mergeTwoInput.connect( groupReturn )
Send Port Example
The Group node created in Return Port Example does not take any inputs. For a group to accept inputs, it must have
an input port linked to its Send port. For example, create a group that merges geometry from a PrimitiveCreate node
inside the group, with geometry from a PrimitiveCreate node outside the group:
# Create the group at root level
root = NodegraphAPI.GetRootNode()
group = NodegraphAPI.CreateNode( 'Group', root )
# Create input and output on the group
group.addInputPort( "in" )
group.addOutputPort( "out" )
# Get the corresponding Send and Return ports
groupOut = group.getReturnPort( "out" )
groupIn = group.getSendPort( "in" )
# Create a PrimitiveCreate node at group level
primitiveGroup = NodegraphAPI.\
CreateNode('PrimitiveCreate', group)
primitivePosition = ( 0, 100 )
23 NODEGRAPH API | GROUP NODES