Home/ Reference/ Document

doc.EndCommandGroup()

Closes the undo group. It must pair with Begin, including in a finally block — if an exception skips it, CDR stays stuck inside the group.

Signature

doc.EndCommandGroup()

Notes

Closes the undo group. It must pair with Begin, including in a finally block — if an exception skips it, CDR stays stuck inside the group.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
doc.BeginCommandGroup("rename demo")
try:
    layer = doc.ActivePage.ActiveLayer
    s = layer.CreateRectangle2(0, 0, 80, 40)
    s.Name = "test rect"
finally:
    doc.EndCommandGroup()               # must be paired with the Begin call

print("Undo group closed")

About this section: Document

Document — documents and file handling.

Other entries in this section