Trees | Indices | Help |
|
---|
|
Contains the undo engine allowing to adjust the scene with api commands while providing full undo and redo support.
- modify dag or dg using the undo-enabled DG and DAG modifiers
- modify values using Nodes and their plugs (as the plugs are overridden to store undo information)
- You cannot mix mel and API proprely unless you use an MDGModifier.commandToExecute
- Calling operations that flush the undo queue from within an undoable method causes the internal python undo stack not to be flushed, leaving dangling objects that might crash maya once they are undon.
- WORKAROUND: Mark these methods with @notundoable and assure they are not called by an undoable method
- calling MFn methods on a node usually means that undo is not supported for it.
To globally disable the undo queue using cmds.undo will disable tracking of opeartions, but will still call the mel command.
Disable the 'undoable' decorator effectively remove the surrounding mel script calls by setting the MRV_UNDO_ENABLED environment variable to 0 (default 1). Additionally it will turn off the maya undo queue as a convenience.
If the mrv undo queue is disabled, MPlugs will not store undo information anymore and do not incur any overhead.
- decorate with @undoable
- minimize probability that your operation will fail before creating an operation (for efficiency)
- only use operation's doIt() method to apply your changes
- if you raise, you should not have created an undo operation
|
|||
UndoCmd | |||
Utilities | |||
---|---|---|---|
MuteUndo Instantiate this class to disable the maya undo queue - on deletion, the previous state will be restored |
|||
StartUndo Utility class that will push the undo stack on __init__ and pop it on __del__ |
|||
UndoRecorder Utility class allowing to undo and redo operations on the python command stack so far to be undone and redone separately and independently of maya's undo queue. |
|||
Operations | |||
Operation Simple command class as base for all operations All undoable/redoable operation must support it |
|||
GenericOperation Simple oeration allowing to use a generic doit and untoit call to be accessed using the operation interface. |
|||
GenericOperationStack Operation able to undo generic callable commands (one or multiple). |
|||
DGModifier Undo-aware DG Modifier - using it will automatically put it onto the API undo queue |
|||
DagModifier undo-aware DAG modifier, copying all extra functions from DGModifier |
|
|||
|
|||
|
|||
Initialization | |||
---|---|---|---|
|
|||
Utilities | |||
|
|||
|
|||
|
|||
|
|||
|
|||
Decorators | |||
|
|||
|
|||
|
|
|||
_undo_enabled_envvar = "MRV_UNDO_ENABLED"
|
|||
_should_initialize_plugin = int(os.environ.get(_undo_enabled_e
|
|||
Undo Plugin | |||
---|---|---|---|
isUndoing = api.MGlobal.isUndoing
|
|||
undoInfo = cmds.undoInfo
|
|||
_maya_undo_enabled = int(os.environ.get(_undo_enabled_envvar,
|
|
Note: will only load the plugin if the undo system is not disabled |
Note: prefer the @undoable decorator |
Note: prefer the @undoable decorator |
Note: can be used if you need control over undo in very specific operations and in a well defined context |
Decorator wrapping func so that it will start undo when it begins and end undo when it ends. It assures that only toplevel undoable functions will actually produce an undo event To mark a function undoable, decorate it: >>> @undoable >>> def func(): >>> pass Notes:
|
Note: can only be employed reasonably if used in conjunction with undoAndClear as it will restore the old state of the undoqueue afterwards, which might be off, thus rendering attempts to undo impossible |
Notes:
|
|
_should_initialize_plugin
|
_maya_undo_enabled
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Apr 19 18:00:12 2011 | http://epydoc.sourceforge.net |