User guide

162
node referenced by node enter the following:
# Get the root node
root = NodegraphAPI.GetRootNode()
# Create a new node at root level
node = NodegraphAPI.CreateNode('PrimitiveCreate', root)
nodesToSerialize = [ node ]
xmlTree = NodegraphAPI.BuildNodesXmlIO( nodesToSerialize )
NOTE: BuildNodesXmlIO() accepts a sequence of nodes, so a network of nodes can be serialized in a
single operation.
Deserialize
Use Paste() in the KatanaFile module to deserialize an xmlTree. The xmlTree can contain an arbitrary number of
nodes, and the contents are pasted under a given location (which can be either /root or a Group node).
For example, to paste the XML created in Serialize to XML under /root enter the following:
root = NodegraphAPI.GetRootNode()
KatanaFile.Paste( xmlTree, root )
Printing An XML Tree
It can be useful to print the serialized XML tree of a node to see what it contains. For example, to view the XML of the
merge in the example above node enter the following:
print( xmlTree.writeString() )
Which - depending on your Katana version - prints:
<katana release="1.5" version="1.5.1.000001">
<node name="__SAVE_exportedNodes" type="Group">
<node baseType="Merge" name="Merge" type="Merge"
x="228.000000" y="-311.000000">
<port name="input" type="in"/>
<port name="Second" type="in"/>
<port name="output" type="out"/>
<group_parameter name="Merge">
<string_parameter name="showAdvancedOptions"
value="No"/>
<group_parameter name="advanced">
<string_parameter name="sumBounds" value="No"/>
<string_parameter name="preserveWorldSpaceXform"
value="No"/>
23 NODEGRAPH API | DUPLICATING NODES