Revert to original file
Copy link to clipboard
Copied
Hey, I am looking for a way to revert my file to its original state after I run my script. I have been unable to find a way to do this. Is there a function that does this with Javascript? Or is it possible to have illustrator simply close the active document, then reopen it?
Explore related tutorials & articles
Copy link to clipboard
Copied
Not sure I follow. Illustrator already has a Revert option within the File menu.
Copy link to clipboard
Copied
Sorry, I want to be able to use the revert option using javascript, so I can include it in a script that I have built
Copy link to clipboard
Copied
app.undo() works as if you use undo manually, you might have to use it multiple times. Unfortunately I'm not sure if you can go back to a specific point in the undo history.
Copy link to clipboard
Copied
This works:
app.executeMenuCommand("revert");
Not sure how to bypass the dialog though.
Copy link to clipboard
Copied
I have the same question, and did run into the problem of dialog.
The statement that I used is: app.doScript ("Revert", "Default Actions");
which is a default action that comes with the system.
Look like I'll just have to close (without saving) and re-open.
Actually, if there were some way of finding out how many undos there are, I could just use undo, which may be a little faster than closing and opening. But, then, I am not confident that Illustrator's undo/redo history is truly complete and reliable.
By the way, I am running Illustrator 2020 v.20.1.3(64bit) (CS6) , and there is no executeMenuCommand command.
Copy link to clipboard
Copied
@carlyuanliu
I'm confused about your message here.. You seem to be saying some contradictory things.
Are you using Illustrator 2020? Or are you running Illustrator CS6? Or are you using Illustrator 20.1.3?
If you're using Illustrator 2020 or CS6, then you do have access to executeMenuCommand();
If you are using v20.1.3, and you're using the "revert" default action, look to the left hand side of the actions panel. The checkmark on the far left means that that step of the action is "active". If you uncheck that box, that step will be skipped. On some steps of the action, you'll see a square just to the right of the checkbox. this box indicates whether or not to show the dialog associated with that step. In most cases, you should be able to click that square to disable the dialog while the action is running.
Hope this helps.
Copy link to clipboard
Copied
what about:
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
There are some things this fixes, and others that it doesn't. Worth a shot.
Note: let's say this setting causes you to miss certain other important dialogs for some reason.. No worries. you don't need to use this setting for your whole script. you could set the interaction level before using "revert" and then reset the interaction level right after that.

