weird interaction between a script and undo history
I'm writing a script that, among other things, arranges artboards. here's the code it uses to move an artboard along with its art:
var doc = app.activeDocument;
//Board Object Constructor
function Board (index){
this.artboard = doc.artboards[index];
this.width = this.artboard.artboardRect[2]-this.artboard.artboardRect[0];
this.height = this.artboard.artboardRect[1]-this.artboard.artboardRect[3];
doc.artboards.setActiveArtboardIndex(index);
doc.selectObjectsOnActiveArtboard();
this.art = app.selection;
app.selection = [];
this.setPosition = function(x,y){
for(var i=0; i<this.art.length; i++){
this.art[i].position = [
this.art[i].left-this.artboard.artboardRect[0]+x,
this.art[i].top-this.artboard.artboardRect[1]+y
];
}
this.artboard.artboardRect=[x,y,x+this.width,y-this.height];
}
}
var boardOne = new Board(0);
var boardTwo = new Board(1);
boardTwo.setPosition(0,0);
boardOne.setPosition(-1000,1000);
The script does it's job as expected, but when I hit ctrl+z after running the script, there seems to be a glitch when reverting back to the previous state. Specifically point-type text does not revert to its previous position. Artboards, shapes, symbols, linked images, single anchor points, and area type will all revert to their previous positions, but point type does not revert.
If the point type was created and/or edited after opening the file, I can continue to press ctrl+z and when i reach a point in the history that affects the point type, it will revert to that state, but the state it was in directly prior to running the script is lost. If the first thing I do after opening a file is run the script, there is no way to restore the text to its previous position without reopening the file.
I'd like to find a way to make ctrl-z fully functional in case the final script has unintended results.
