Home/ Reference/ Document

doc.BeginCommandGroup(commandName)

Opens an undo group; everything after it collapses into one entry in the undo list. Mandatory for big jobs, otherwise the user has to hit Ctrl+Z several hundred time

Name

doc.BeginCommandGroup(commandName)

Notes

Opens an undo group; everything after it collapses into one entry in the undo list. Mandatory for big jobs, otherwise the user has to hit Ctrl+Z several hundred times.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
doc.BeginCommandGroup("batch rectangles")     # open an undo group: later operations collapse into one step
try:
    for i in range(3):
        layer = doc.ActivePage.ActiveLayer
        layer.CreateRectangle2(i * 100, 0, 80, 50)
finally:
    doc.EndCommandGroup()               # close it on error too, or CorelDRAW stays stuck inside the group

print("Done; a single Ctrl+Z undoes the whole batch")

About this section: Document

Document — documents and file handling.

Other entries in this section