Copy link to clipboard
Copied
Just wondering if there is an equivalent to Photoshop:
app.activeDocument.suspendHistory("Heres my undo state", 'main()')
or InDesign:
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Heres my Undo State");
While Illustrator does have doScript, it's only for Actions from what I gather. Any googling of suspend history brings up Photoshop implementations. Anything similar for Illustrator?
Copy link to clipboard
Copied
There are no suspendHistory or undoModes in Illustrator.
I tried changing the undoDepth since it seems the History steps are related to the number of undos. But it seems the minimum number of undos is 5. Are you trying to prevent a large number of undos in memory?
app.preferences.setIntegerPreference ("maximumUndoDepth", 5);
Copy link to clipboard
Copied
Hi @wckdtall, the situation with scripting and Undo/Redo in Illustrator is not as good. Here are my observations:
1. Most scripting operations will not add to the Undo stack, but some will. I don't know which will or won't but the majority wont in my experience. Therefore the whole script will usually be undo-able in one go. My guess is the less reliant on UI style calls, eg. executeMenuCommand, the more likely the whole script will add just one operation to the Undo stack.
2. If you want to have multiple operations added to the Undo stack, you can force it by calling app.redraw() in your script. If you are looping over an array, adding app.redraw() into the loop will give you one undo operation for each iteration.
- Mark
Copy link to clipboard
Copied
Thanks both! I'm actually wanting to wrap several actions into one history state. My script creates a layer, names it, makes a text disclaimer, outlines it, sets visibility. It consistently only records 2 undo states, but in PS and ID an entire loop with hundreds of changes can be contained within these so they don't record. I do use redraw quite a bit, but mostly because Illustrator needs it to update scripts that run too fast. On that note, it may be in part why such this functionality doesn't exist.