Batch undo group
Wrap big jobs in BeginCommandGroup / EndCommandGroup and one Ctrl+Z in CDR undoes the whole thing.
Scenario
Batch undo group
Notes
Wrap big jobs in BeginCommandGroup / EndCommandGroup and one Ctrl+Z in CDR undoes the whole thing.
Python example (runnable)
Requires
pywin32. The example assumes app / doc / page / layer are already connected.
See Connection & InitPython
doc.BeginCommandGroup("Generate 20 pages")
try:
layer = doc.ActivePage.ActiveLayer
for i in range(20):
layer.CreateRectangle2(0, i * 10/25.4, 50/25.4, 8/25.4)
finally:
doc.EndCommandGroup() # must sit in finally so errors still close it
print("Done; a single Ctrl+Z undoes the whole batch")
About this section: Recipes
Recipes — copy-paste ready workflows.
- This section has 6 entries; this is one of them.
- See the full section index: Recipes
Other entries in this section
- Throttling: why time.sleep(0.2) appears everywhereCorelDRAW is a single-threaded STA server. Python issues commands far
- Set font, read back, then fall backSee the code below. This is the most valuable pattern in the entire sc
- Verify the font before converting to curvesConverting to curves is irreversible, so the order is fixed: set the f
- Process in index-range batchesWith a lot of JSON records, run start/end slices and print "total / pa
- Skip missing data instead of raisingif not img_find_in: skip_cnt += 1; continue — a missing image gets cou