Skip to main content
Upendra_sengar
Inspiring
July 23, 2015
Question

How can i revert all the changes made onto the document through jsx script ?

  • July 23, 2015
  • 3 replies
  • 1727 views

i want any of the way that can help me to revert all the changes that are made on the document ,like through Jsx script  I made changes in the document like placing image re-sizing image changing swatches etc. but at a point of time i want to revert all the changes made through the same jsx code. i'm aware of undo function in Jsx but undo  function  just revert the recent change (can say last change ) so ,is there any way that can be used to revert all the changes.

Note: one way i know that is to close the document without save changes and reopen the same document. but avoiding this solution.

This topic has been closed for replies.

3 replies

Qwertyfly___
Legend
July 27, 2015

any reason you want to avoid closing without saving and reopening?

Revert just closes the document and re opens it.

no need to call revert when the process is so simple to just close and re open.

its even less lines of code then the example below, which does not work!

WARNING - This will not work!!!!

var originalInteractionLevel = userInteractionLevel;

userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

app.executeMenuCommand('revert');

userInteractionLevel = originalInteractionLevel;

user interaction stops the revert dialog, but also does not run it

This is what I would do...

timer = Date.now();

//

var myFile = File(app.activeDocument.path + '/' + app.activeDocument.name);

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 

app.open(myFile);

//

var x = (Date.now()-timer);

alert('completed in:\n' + Math.floor(x/1000/60) + ' Minutes, ' + Math.floor(x/1000%60) + ' Seconds, and ' + x%1000 + ' Milliseconds');

ran this many times on an .ai file over 50mb.

under 4 seconds every time.

Inspiring
July 23, 2015

app.executeMenuCommand('revert'); works on Illustrator versions above CS6, but it does bring up a dialog.

Upendra_sengar
Inspiring
July 24, 2015

is there any way to not to show dialog if it happens then i can be the solution.

Inspiring
July 24, 2015

QwertyFly has a script that suppresses dialogs using userInteractionLevel here Re: Is it possible, using javascript, to copy and rename an existing document? The copy I've managed, and resized the a…

var originalInteractionLevel = userInteractionLevel;        //save the current user interaction level 

userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;      //Set user interaction level to suppress alerts 

doc.saveAs(myFile,saveOpts);        //Save File 

userInteractionLevel = originalInteractionLevel;        //Set user interaction level back to original settings 


Just replace the save as with your revert.

CarlosCanto
Community Expert
Community Expert
July 23, 2015

what happens if you keep Undoing?

Upendra_sengar
Inspiring
July 24, 2015

I can't undo because i don't want to keep track of changes made in the document ,