Script saves and closes file, then immediately reopens it
I have a script that I've been using for close to 10 years with some minor adjustments... basically the idea is to take the artwork from a proof and calculate how much the image must be condensed in the x-direction in order to compensate for the stretch/distortion that happens when a flat flexographic plate is wrapped around a print cylinder.
Anyway, it condenses the width of the selected art, copies the condensed image to the clipboard, expands the image back out to the size it was on the proof, resaves the proof, and closes the file. Worked perfectly until yesterday. Now it does all that but after it closes the proof it reopens it. It's really driving me nuts.... I'm guessing it's some update within illustrator or something? The script hasn't been changed.
// required: an open document and a selected path item
var myDocument = app.activeDocument;
var selectedObject = myDocument.selection[0];
//Identify left edge of repeat
var repeatBounds = app.activeDocument.groupItems['repeat'].geometricBounds;
var r1 = repeatBounds[0];
// Get position of selection bounds and create condense ratio
var myBounds = selectedObject.geometricBounds;
var x1 = myBounds[0];
var x2 = myBounds[2];
var rawRepeat = (r1 - x1);
var rawGap = (r1 - x2);
var rawPrintWidth = myBounds[2] - myBounds[0];
var condenseRatio = ((rawRepeat - 23) / rawRepeat) * 100;
var expandRatio = (100/condenseRatio) * 100;
selectedObject.resize(
condenseRatio, // x
100.0, // y
true, // changePositions
true, // changeFillPatterns
true, // changeFillGradients
true, // changeStrokePattern
true , // changeLineWidths
Transformation.LEFT); // scaleAbout
copy();
selectedObject.resize(
expandRatio, // x
100.0, // y
true, // changePositions
true, // changeFillPatterns
true, // changeFillGradients
true, // changeStrokePattern
true, // changeLineWidths
Transformation.LEFT); // scaleAbout
if ( app.documents.length > 0 ) {
aiDocument = app.activeDocument;
aiDocument.close( SaveOptions.SAVECHANGES );
aiDocument = null;
}
Any help would be greatly appreciated. Thanks.
