PyDoc: Document the undo argument when calling operators

Ref !160359
This commit is contained in:
Olayinka Vaughan 2026-07-19 12:20:55 +00:00 • committed by Campbell Barton
parent ecabdd1903
commit ff0f71d96e

View file

@ -0,0 +1,24 @@
"""
.. _operator-undo:
Undo
----
The optional second positional argument is a boolean that controls whether the
operator call is pushed onto the undo stack.
It defaults to ``False``, so operators run from a script do not add to the undo
history. Pass ``True`` when you want the call to be undoable, for instance when
a script performs an edit the user should be able to undo interactively.
If this call happens while nested inside another operator call, the argument
has no effect: the outer call already suppresses undo for everything nested
inside it, and that only lifts once the outer call returns.
Like the execution context this argument is optional, but the positional order
must be kept, so the execution context is given first.
"""
# Add a cube as an undoable operator call.
import bpy
bpy.ops.mesh.primitive_cube_add('EXEC_DEFAULT', True)