User guide

165
merge.setName( 'Result' )
NOTE: Ctrl+middle-click on the Group node to see its contents, and observe the PrimitiveCreate nodes
named Sphere and Cube, with their outputs connected to the input of a Merge node.
View the Merge node, and expand the Scene Graph to see the two scene graph locations created by the
two Primitive Create nodes.
Send and Return Ports
The example created in A Group Node Example has no connections to or from the Group node. For Group nodes to
be of any significant use, you need to be able to connect their internal structure to the ports of external nodes. The
quickest - in the short term - way of doing this is to directly connect a port on a node inside the group to a port on a
node outside the group. To do this however, you need to know the internal structure of the Group node and be
aware of the maintenance burden on the Python code that does the connecting. Any change to the internal
structure of the group can mean the port connecting code needs updating.
A more encapsulated approach is to connect the internal ports to corresponding Send or Return ports on the
Group node. If a Group node were a function in Python, the Send ports would be the arguments and the Return
ports would the return values.
NOTE: The Send and Return ports on a Group node only exist if the group has inputs and outputs
created. Creating an input or output port on a group automatically creates a Send or Return port with the
same name.
See Input and Output Ports for more on creating, and connecting inputs and outputs.
Return Port Example
The advantage of Send and Return ports is that you can connect to them without any knowledge of the group’s
internal structure. For example, create a Group containing a PrimitiveCreate node and a Merge node. Connect the
output of the PrimitiveCreate node to the input of the Merge node, and connect the output of the Merge node to
the Return port of the Group node:
# Create the group at root level
root = NodegraphAPI.GetRootNode()
group = NodegraphAPI.CreateNode( 'Group', root )
group.addOutputPort( "out" )
# Create the PrimitiveCreate node at group level
primitive = NodegraphAPI.CreateNode( 'PrimitiveCreate',\
group)
# Create a Merge nodes at group level
mergeOne = NodegraphAPI.CreateNode( 'Merge', group )
23 NODEGRAPH API | GROUP NODES