Package autodesk_toxik :: Module graph :: Class Node
[frames] | no frames]

Class Node

 object --+    
          |    
Boost.Python.instance --+
              |
             Node
Known Subclasses:

Represents a node within a graph.

Bracket-operator Input/Output Fetch Syntax

You can use the [] operator on a node to get an input or output directly. For example, if a is a node instance:

   a['foo']

returns the input (or output) with name 'foo'. You can fetch an input/output pair by using two parameters. For example:

   a['input-name', 'output-name'] # return a (input, output) tuple

This is useful in conjunction with the right-shift connection syntax described below.

Right-Shift Connection Syntax

You can use the following connection syntax to easily connect inputs and outputs. You can use the right-shift operator (>>) to build connections such as:

   <node-input-or-output> >> <node-input-or-output>[>> <node-input-or-output> ...]

For example, assuming a, b and c are created node instances, all of the following are valid constructs:

   # connect named output on a to named input on b
   a['output-name'] >> b['input-name']

   # to chain more than one connection, the most explicit way is to use a tuple
   a['output-name'] >> (b['input-name'], b['output-name']) >> c['input-name']

   # or more simply...
   a['output-name'] >> b['input-name', 'output-name'] >> c['input-name']

Resolving Ambiguities

If you specify an input socket on the left side of a connection, it is replaced by the corresponding node of that input. If you specify a node on the left side of a connection, the connection algorithm attempts to find an output on the node matching the type of the input on the right side of the >> operator. Conversely, if you specify an output socket on the right side, it is replaced by the corresponding node of that output. If you specify a node on the right side, the connection algorithm attempts to find an input on the node matching the type of the output on the left side of the >> operator. However, if you specify only nodes on both sides, an algorithm looks successively at each output of the node on the left, and attempts to find an input of matching type on the node on the right. It continues until a match is found. An ambiguous syntax should be used only in cases where there is no ambiguity (i.e. the node on the left has a single output, and/or the node on the right has a single input of the specified type). As this is often the case, this is a convenient way to connect nodes with minimal syntax.

For example:

   # connect one of a's outputs to one of b's default inputs
   a >> b

   # you can chain with nodes only as well
   a >> b >> c['input-name']

   # in this case b's input is fetched automatically
   a >> b['output-name'] >> c

Using these techniques you could create all your node instances and then make all the connections very simply in a few lines.

Note that if there is an input and an output with the same name, you must disambiguate by calling getInput() or getOutput() instead of using the bracket notation to get an input/output.

Instance Methods
 
__cmp__(...)
 
__getitem__(...)
 
__init__(...)
Raises an exception This class cannot be instantiated from Python
 
__reduce__(...)
helper for pickle
 
__rshift__(...)
 
addAnchor(...)
Adds an anchor to this node.
Value
addValue(...)
Creates new dynamic value, adds it to this node and returns it.
 
enableSchematicThumbnail(...)
Enables/disables the thumbnail on this node in the schematic.
[tuple]
getAnchors(...)
Returns: The list of anchors on this node.
Graph
getGraph(...)
Returns: The version (composition graph) that owns this node.
GroupNode
getGroup(...)
Returns: The group node to which this node belongs.
int
getId(...)
Returns: Unique identifier of the node within its graph.
Input
getInput(...)
Returns: A node input socket by name.
[Input]
getInputs(...)
Returns: The list of input sockets on this node.
str
getName(...)
Returns: The node name.
Output
getOutput(...)
Returns: A node output socket by name.
[Output]
getOutputs(...)
Returns: The list of output sockets on this node.
Input
getPrimaryImageInput(...)
Shortcut for getPrimaryInput( DataTypeType.IMAGE ).
Output
getPrimaryImageOutput(...)
Shortcut for getPrimaryOutput( DataTypeType.IMAGE ).
Input
getPrimaryInput(...)
Returns: The node's primary/first input of the given type.
Input
getPrimaryOutput(...)
Returns: The node's primary/first output of the given type.
str
getQualifiedName(...)
Returns: The fully qualified name of the node.
tuple
getSchematicPosition(...)
Returns: The position of the node in the schematic as an (x, y) float tuple.
Value
getValue(...)
Returns: A node value by name.
[Value]
getValues(...)
Returns: The list of values on this node.
bool
hasAnchor(...)
Returns: True if the node has the specified anchor.
bool
isSchematicThumbnailEnabled(...)
Returns: Whether the schematic thumbnail is enabled on this node.
 
removeAnchor(...)
Removes the specified anchor from this node.
 
removeValue(...)
Removes an existing dynamic value Value from this node.
 
setAnchors(...)
Sets a list of anchors on this node.
 
setName(...)
Sets the name of the node.
 
setSchematicPosition(...)
Sets the (x, y) position of the node in the schematic.

Inherited from Boost.Python.instance: __new__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(...)
(Constructor)

 

Raises an exception This class cannot be instantiated from Python

Overrides: object.__init__

__reduce__(...)

 

helper for pickle

Overrides: object.__reduce__
(inherited documentation)

addAnchor(...)

 

Adds an anchor to this node.

Parameters:
  • anchor (tuple) - A tuple of anchor type and anchor name which are both unicode strings.

addValue(...)

 

Creates new dynamic value, adds it to this node and returns it.

Parameters:
Returns: Value
The new dynamic value.

enableSchematicThumbnail(...)

 

Enables/disables the thumbnail on this node in the schematic.

Parameters:
  • enabled (bool) - Whether to enable or disable the thumbnail.

getAnchors(...)

 
Parameters:
  • type (str) - Optional argument that specifies which type of anchors to get. Defaults to "".
Returns: [tuple]
The list of anchors on this node. An anchor is a tuple of anchor type and anchor name which are both unicode strings.

getGraph(...)

 
Returns: Graph
The version (composition graph) that owns this node.

getGroup(...)

 
Returns: GroupNode
The group node to which this node belongs.

getId(...)

 
Returns: int
Unique identifier of the node within its graph.

getInput(...)

 
Parameters:
  • name (str)
Returns: Input
A node input socket by name.

getInputs(...)

 
Returns: [Input]
The list of input sockets on this node. Some input sockets (StructuredInput) are recursive: they may contain other inputs, but the function only returns "root" inputs.

getName(...)

 
Returns: str
The node name.

getOutput(...)

 
Parameters:
  • name (str)
Returns: Output
A node output socket by name.

getOutputs(...)

 
Returns: [Output]
The list of output sockets on this node.

getPrimaryInput(...)

 
Parameters:
Returns: Input
The node's primary/first input of the given type.

When the type is set to DataTypeType.UNKNOWN (default), the primary input of the node is returned or None if there is no primary input.

When an actual socket type is specified and the node does not have a primary input of the given type, the first input of that type is returned. If the node doesn't have any input of the given type, None is returned.

getPrimaryOutput(...)

 
Parameters:
Returns: Input
The node's primary/first output of the given type.

When the type is set to DataTypeType.UNKNOWN (default), the primary output of the node is returned or None if there is no primary output.

When an actual socket type is specified and the node does not have a primary output of the given type, the first output of that type is returned. If the node doesn't have any output of the given type, None is returned.

getQualifiedName(...)

 
Returns: str
The fully qualified name of the node. It is of the form: "outerGroup.enclosingGroup.nodeName".

getSchematicPosition(...)

 
Returns: tuple
The position of the node in the schematic as an (x, y) float tuple.

getValue(...)

 
Parameters:
  • name (str)
Returns: Value
A node value by name.

getValues(...)

 
Returns: [Value]
The list of values on this node.

hasAnchor(...)

 
Parameters:
  • anchor (tuple) - A tuple of anchor type and anchor name which are both unicode strings.
Returns: bool
True if the node has the specified anchor.

isSchematicThumbnailEnabled(...)

 
Returns: bool
Whether the schematic thumbnail is enabled on this node.

removeAnchor(...)

 

Removes the specified anchor from this node. Attempting to remove an anchor that doesn't exist is a no-op.

Parameters:
  • anchor (tuple) - A tuple of anchor type and anchor name which are both unicode strings.

removeValue(...)

 

Removes an existing dynamic value Value from this node.

Parameters:
  • value (Value or str) - Value or name of the value.

setAnchors(...)

 

Sets a list of anchors on this node. Previous anchors, if any, are discarded. An anchor is a tuple of anchor type and anchor name which are both unicode strings.

Parameters:
  • anchorList (list of tuple) - List of (type, name) anchors.

setName(...)

 

Sets the name of the node.

Parameters:
  • name (str)

setSchematicPosition(...)

 

Sets the (x, y) position of the node in the schematic.

Parameters:
  • x (float) - Node horizontal position.
  • y (float) - Node vertical position.