Node

class guerilla.Node

Bases: object

Base class of all the document’s nodes.

Name

The node name

Type:str
belongstoreference(ref)

Tells if the node belongs to the reference, or a sub reference

Parameters:ref (Reference) – The reference to test
Returns:true is the node belongs to the reference or a sub reference
Return type:bool
children(type='Node', pattern=None, recursive=None)

Iterator over children

Examples:

>>> import guerilla
>>> for node in guerilla.Document ().children (pattern="^Bott.*"): # iterate over the root nodes of Document named 'Bott...'
...     print (node.getpath ())
Bottom
>>> import guerilla
>>> for node in guerilla.Document ().children ("Camera"): # iterate over the root Camera nodes of Document
...     print (node.getpath ())
Right
Back
Perspective
Bottom
Top
Front
Left
>>> import guerilla
>>> for node in guerilla.Document ().children ("Light", recursive=True): # iterate over all the Light nodes of Document
...     print (node.getpath ())
Parameters:
  • type (str) – only return node with given type, ex. SceneGraphNode, Texture…
  • pattern (str) – pattern to match the name of the node, leave to None for no matching
  • recursive (bool) – indicate if the iterator should recurse in hierarchy for sub children
Return type:

iterator

static create(name, type='SceneGraphNode', parent=None)

Create a node Use current modification context if available

Examples:

>>> n = Node.create('foo'); n.name 
'foo...'
>>> n = Node.create('bar', type='STEREOCAMERA') 
Traceback (most recent call last):
ValueError: not a valid node type: STEREOCAMERA
>>> n = Node.create('bar')
>>> n2 = Node.create('cbar', parent=n); n2.getpath() 
'bar...|cbar'
createplug(name, plugType='Plug', dataType='string', flags=0, value=None)

Create a Plug on node Use current modification context if available see. createplug function in Modifier class

delete()

Delete a node

eval(plug)

Called by the framework when plug (a node’s plug) must be evaluated

Parameters:plug (Plug) –
Returns:The evaluated plug value
Return type:<i>any</i>
findchild(path)

Find a child node or plug using a path

Parameters:path (str) – the child node or plug path
Returns:the child node or plug
Return type:Node or Plug
findparent(name)

Find the first parent Node of this Node of a specific class

Parameters:name (str) – the parent’s class
Returns:the node’s parent
Return type:Node
getchild(name)

Get a child node by its name

Parameters:name (str) – the child name
Returns:The child node
Return type:Node
getname()

Get the Node name in its parent

Returns:The Node name
Return type:[string or number]
getparent()

Get the parent Node of this Node

Returns:the node’s parent
Return type:Node
getpath()

Node path

Returns:node path (ie. long name)
Return type:str
getreference()

Returns the reference node it is connected to

Returns:the reference node or None if not referenced
Return type:Reference
getreferences(Reference=None)

Returns the references in the document sorted depth first.

Parameters:Reference (topref) – an optional top reference
Returns:references
Return type:of
getstringcopy()

Return a copy of the node and its content as a string to be pasted

Returns:The string copy
Return type:str
gettopreference()

Returns the top reference node it is connected to

Returns:the top reference node or None if not referenced
Return type:Reference
hasAttr(name, type)

Check whether a child node or plug of given type exists

Parameters:
  • name (str) – child node or plug name
  • type (str) – ‘Plug’ or ‘Node’
hasChild(name)

Check whether a child exists or not

Parameters:name (str) – child name
Returns:True if child exists else False
Return type:bool
hasPlug(name)

Check whether a plug exists or not

Parameters:name (str) – plug name
Returns:True if plug exists else False
Return type:bool
iseditable()

Indicates if the node can be edited by the user in the UI

The default behaviour is to return true if no IsEditable plug exists, otherwise it returns the IsEditable plug value. To render a node non editable, create a IsEditable dynamic plug, and set its value to false. Alternatively, use the seteditable function.

Returns:true if the node can be edited
Return type:bool
ismoveable()

Tells if the node can be moved

Returns:True if the node can be moved
Return type:bool
isparent(child)

Tells if this node is parent of the potential child

Parameters:child (Node) – the potential child to check
Return type:bool
isreference()

Tells if a node comes from a reference project

Returns:true if the node is a reference
Return type:bool
isselected()

Tell if the node is selected

Returns:true if the node is selected
Return type:bool
loadfile(filename, options=None)

load a file content in this node. Possible options are: overrideclass to enforce a specific class for the root node.

Parameters:
  • filename (str) – The file name to load
  • options (table) – Loading options as a table/dictionary
Returns:

The created nodes or None if failed

Return type:

{Node}

loadtemplate(template, name)

load a template file

Parameters:
  • template (str) – The template file name to load
  • name (str) – The loaded template name to use
Returns:

The created node or None if failed

Return type:

Node

move(parent)

Move a node to a new parent

Parameters:parent (Node) – The new parent node
name

Node name

Returns:node short name
Return type:str
onpathchanged()

Called by the framework when the name of this node or of one of its parent is modified

parent

Parent of this node

Returns:parent Node or Document
Return type:Node or Document
pastestringcopy(copy)

Paste a string copy into this node

See also getstringcopy for an example of copy/pasting.

Parameters:copy (str) – The string copy to paste
Returns:The pasted nodes, or None if failed and an error message
Return type:{Node},string
path

Node long name

Returns:node long name
Return type:str
plugs(type='Plug', typename=None)

Iterator over all plugs in Node

Return type:iterator
referencefile(name, refpath, options=None)

reference a file content in this node.

This method is used to load a single node saved to a file using the savefile method,

Parameters:
  • name (str) – the reference node name
  • refpath (str) – the referenced file path
  • options (table) – the reference options
Returns:

the resulting reference node

Return type:

ReferenceBase

rename(name)

Rename a node Use current modification context if available

Parameters:name (str) – node new name
savefile(filename)

load a node to a file

Parameters:filename (str) – The file name to save
Returns:True if success, or None and an error message
Return type:bool,string
seteditable(editable)

Change the editable state of the node

Parameters:editable (bool) – The new state of the node
setflags()

Set the node flags