Modifier¶
-
class
guerilla.
Modifier
¶ Bases:
object
Modification context
In order to keep a coherent undo/redo stack during all user interactions, some operations cannot be directly performed, but rather through a wrapper, the modification context.
Use it as a context manager (using the ‘with’ keyword) or retrieve the current modification context using static method ‘get’
Examples:
>>> from guerilla import Modifier, pynode >>> with Modifier() as mod: ... mod.createnode('foo') <guerilla.SceneGraphNode object at ...> >>> foo_node = pynode('foo')
>>> # retrieve current modification context >>> m = Modifier.get()
-
adddependency
(input, output)¶ Add dependency of an output plug on an input plug
Parameters:
-
connect
(input, output)¶ Connect a plug to another
Parameters: Raise: RuntimeError if adddependency must be used (non typed plug)
-
createnode
(name, type='SceneGraphNode', parent=None)¶ Create a node
Parameters: Returns: created node
Return type: Raise: ValueError if type is unknown or a Reference or Document
-
createplug
(node, name, plugType='Plug', dataType='string', flags=0, value=None)¶ Create a plug
Parameters: Returns: plug instance
Return type: DynAttrPlug
orPlug
Raise: AttributeError raise an exception if plug already exists
Available types (dataType):
- int, float, bool, angle,
- string
- color,
- enum, filename, directory
See also
types
for all available types>>> import guerilla >>> n = Node.create('foo'); n.createplug('bar', dataType='angle') <guerilla.Plug object at ...>
>>> n = Node.create('foo'); p = n.createplug('bar', dataType='color') >>> p.set([0,255,255]); print p.get() [0L, 255L, 255L]
>>> n = Node.create('foo') >>> p = n.createplug('bar', dataType=guerilla.types('enum', desc=['a', 'b'])) >>> p.set('a'); print p.get() a
-
createref
(name, filename, parent=None, options=None, nohostrefs=None)¶ Create a reference
Parameters: Returns: reference node (
ArchReference
) and parent nodes (tuple ofSceneGraphNode
)Return type: >>> from guerilla import Modifier >>> with Modifier() as mod: ... n = mod.createnode('geom') ... # assume objPath1 is the path of an OBJ ... refNode, topNodes = mod.createref('foo', objPath1, n, {'prefixnodes':False,'containschildren':True})
The possible options to create the reference are:
prefixnodes: the referenced nodes are prefixed with the reference name when True
containschildren: the referenced nodes are loaded as children of the Reference, instead of loading in the Document when True
roots: the list of paths to be moved as root in the reference, with all other nodes discarded
-
deletenode
(node)¶ Delete a node
Parameters: node (Node) – node to delete Returns: True on success else False Return type: bool
-
deleteref
(ref)¶ Delete a reference
Parameters: ref ( ArchReference
) – reference node>>> from guerilla import Modifier >>> with Modifier() as mod: ... n = mod.createnode('geom') ... # assume objPath1 is the path of an OBJ (or an alembic) file ... refNode, topNodes = mod.createref('foo', objPath1, n) ... mod.deleteref(refNode) >>> len(list(n.children())) 0
-
disconnect
(input, output)¶ Disconnect a plug from another plug
Parameters:
-
static
get
()¶ Retrieve current modification context
Even if there is no current modification, get will return a valid context.
Returns: current modification context Return type: Modifier
-
movenode
(node, parent)¶ Move node under parent
Parameters: Returns: True on success else False
Return type:
-
removealldependencies
(input)¶ Remove all dependencies off an input plug
Parameters: input ( Plug
) – input plug
-
removedependency
(input, output=None)¶ Removes dependency of an output plug off an input plug or all dependencies if output is None
Parameters:
-
renamenode
(node, name)¶ Rename a Node
Parameters:
-