 |
 |
 |
Python Computer Graphics Kit |
 |
 |
 |
The Node class is a helper class which may be used in a
concrete implementation of the MAReader class to represent
Maya nodes.
This class does not implement the actual functionality of a particular
Maya node, it just tracks attribute changes and connections which can
later be retrieved once the entire file was read. So this class can be
used for all Maya nodes in a file.
| class Node( |
nodetype, opts, parent=None) |
-
nodetype and opts are the arguments of the
onCreateNode() callback of the MAReader class.
parent is either None or another Node object that will
be the parent of the node.
- nodetype
-
This is a string containing the type of the node (this is the value
that was passed to the constructor).
- opts
-
This is the option dictionary that was passed to the constructor
(i.e. that is used to create the node).
-
Return the name of the node. If no node name was specified during the
creation of the object, the dummy name 'MayaNode' is returned.
-
Return the name of the parent node or
None if no parent was specified.
-
Return the parent Node object.
-
parent is either
None to remove the node from its parent
or it is another Node object that will be the new parent.
-
Return an iterator that yields all children Node objects.
| setAttr( |
attr, vals, opts) |
-
attr, vals and opts are the arguments of the
onSetAttr() callback of the MAReader class. The Python
value of an attribute can be obtained by calling getAttrValue().
The final Python value can be retrieved with the getAttrValue()
method.
| getAttrValue( |
lname, sname, type, n=1, default=None) |
-
Get the Python value of an attribute.
lname is the long name, sname the short name. type
is the required type and n the required number of elements
(see the Attribute.getValue() method in section 4.18.4 for more information on the type).
type and n may be None.
The return value is either a normal Python type (int, float, sequence)
or a MultiAttrStorage object in cases where the
setAttr
command contained the index operator. When no attribute with the given long
or short name could be found the provided default value is returned.
-
opts is the arguments of the onAddAttr() callback of
the MAReader class.
| addInConnection( |
localattr, nodename, attrname) |
-
Specify an incoming connection.
nodename is the name of a node and attrname the full
attribute name.
| addOutConnection( |
localattr, node, nodename, attrname) |
-
Specify an outgoing connection.
node is a Node object, nodename the name of the
node and attrname the full attribute name.
| getInNode( |
localattr_long, localattr_short) |
-
Return the node and attribute that serves as input for the local
attribute with long name localattr_long and short name
localattr_short. The return value is a 2-tuple (nodename,
attrname) that specifies the input connection for the
local attribute. (
None, None) is returned if there is
no connection.
| getOutNodes( |
localattr_long, localattr_short) |
-
Return the nodes and attributes that the specified local attribute
connects to. localattr_long is the long name of the local
attribute and localattr_short its short name.
The return value is a list of 3-tuples (node, nodename,
attrname) that specify the output connections for the
local attribute. The tuple contains the values that were previously
added with addOutConnection().
| getOutAttr( |
lname, sname, dstnodetype) |
-
Check if a local attribute is connected to a particular type of node.
Returns a tuple (node, attrname) where node is the
Node object of the destination node and attrname the name of
the destination attribute. If there is no connection with a node of
type dstnodetype, the method returns (
None, None).
If the attribute is connected to more than one node with the given
type or to several attributes of the same node then only the first
connection encountered is returned.
Release 2.0.0alpha8, documentation updated on February 24, 2008.