what happens if you keep Undoing?
app.executeMenuCommand('revert'); works on Illustrator versions above CS6, but it does bring up a dialog.
I can't undo because i don't want to keep track of changes made in the document ,
is there any way to not to show dialog if it happens then i can be the solution.
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.
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.