nuke.Undo
- class nuke.Undo
Bases:
pybind11_objectManages Nuke’s undo/redo system.
All methods are class-level and can be called on the type directly (e.g.
nuke.Undo.begin()) or on an instance. AnUndoinstance can also be used as a context manager: thewithblock opens an undo group on entry and closes it on exit.Example:
with nuke.Undo(): nuke.Undo.name('My Operation') # ... make changes ...
Methods
begin(name=None) -> None
cancel() -> None
disable() -> None
disabled() -> bool
enable() -> None
end() -> None
name(name) -> None
new() -> None
redo() -> None
redoDescribe(n) -> str
redoDescribeFully(n) -> str
redoSize() -> int
redoTruncate(n=0) -> None
undo() -> None
undoDescribe(n) -> str
undoDescribeFully(n) -> str
undoSize() -> int
undoTruncate(n=0) -> None
- static begin(name=None) None
Begin a new user-visible group of undo actions.
- Parameters:
name – Optional label shown in the Edit menu. Can be set or overridden later with name().
- static cancel() None
Undo every action recorded in the current group and discard it.
No entry is added to the undo stack. Safe to call when no group is open (no-op in that case).
- static disable() None
Increment the disable counter, suppressing undo recording.
Each call must be matched by a corresponding enable(). The counter is clamped at zero by enable() so it can never go negative.
- static disabled() bool
Return True if the undo system is currently suppressed.
- static enable() None
Decrement the disable counter (clamped at zero).
Undo recording resumes once the counter reaches zero.
- static end() None
Complete the current undo group and add it to the undo stack.
Empty groups (no recorded actions) are discarded silently.
- static name(name) None
Set or override the label of the current undo group.
Unlike the C++ API, the Python binding always applies the name (forceSetName=true), so this will override a label set by begin().
- Parameters:
name – New label string.
- static new() None
Same as end();begin().
Commits the current group to the undo stack and immediately opens a fresh unnamed group, producing two separate undo entries for actions recorded before and after the call.
- static redo() None
Redo the most recently undone operation.
- static redoDescribe(n) str
Return a short description of the nth redo entry (0 = most recent). Returns an empty string if n is out of range.
- static redoDescribeFully(n) str
Return a long description of the nth redo entry (0 = most recent). Returns an empty string if n is out of range.
- static redoSize() int
Number of redo operations available.
- static redoTruncate(n=0) None
Destroy all redo entries at index >= n.
- static undo() None
Undo the most recent operation.
- static undoDescribe(n) str
Return a short description of the nth undo entry (0 = most recent). Returns an empty string if n is out of range.
- static undoDescribeFully(n) str
Return a long description of the nth undo entry (0 = most recent). Returns an empty string if n is out of range.
- static undoSize() int
Number of undo operations available.
- static undoTruncate(n=0) None
Destroy all undo entries at index >= n.