nuke.Undo

class nuke.Undo

Bases: pybind11_object

Manages 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. An Undo instance can also be used as a context manager: the with block opens an undo group on entry and closes it on exit.

Example:

with nuke.Undo():
    nuke.Undo.name('My Operation')
    # ... make changes ...

Methods

begin

begin(name=None) -> None

cancel

cancel() -> None

disable

disable() -> None

disabled

disabled() -> bool

enable

enable() -> None

end

end() -> None

name

name(name) -> None

new

new() -> None

redo

redo() -> None

redoDescribe

redoDescribe(n) -> str

redoDescribeFully

redoDescribeFully(n) -> str

redoSize

redoSize() -> int

redoTruncate

redoTruncate(n=0) -> None

undo

undo() -> None

undoDescribe

undoDescribe(n) -> str

undoDescribeFully

undoDescribeFully(n) -> str

undoSize

undoSize() -> int

undoTruncate

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.