• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
4

Script saves and closes file, then immediately reopens it

Explorer ,
Dec 06, 2023 Dec 06, 2023

Copy link to clipboard

Copied

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.

TOPICS
Bug , Scripting , Tools

Views

152

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Dec 06, 2023 Dec 06, 2023

Copy link to clipboard

Copied

that's strange, how are you running this script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 07, 2023 Dec 07, 2023

Copy link to clipboard

Copied

Hey Carlos!

 

I'm pretty sure you are one of the people who helped me write this script. I have an action setup (which just resizes the artboard to 100% and outlines any strokes in the art) and the last step of the action is to select  File > Scripts > Condense for Plate. That way I can just use a function key to run the action.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 11, 2023 Dec 11, 2023

Copy link to clipboard

Copied

I've attached a sample file of one of our proof sheets. Once opened—with the first impression of the sample art selected—running the script will condense the artwork, copy it to the clipboard, undo the compression and resave it (this moves all the proofs for which plates have been ordered to the top of the folder index when arranged by "Date modified".

 

Until recently, that was it. The file would close and I could paste the art onto the template we use to submit plate orders to the plate manufacturer. Worked great. Now, it closes but then immediately reopens the file and I have to manually close it so that I can continue. 

 

Anyway, I took the file document.close part out of the script and made save and close the final step in the action that runs the script. That fixed it. It seems a little slower this way, but not enough to really bother me.

 

So I guess it's fixed, although I never figured out why the script (even if I ran it without the action) suddenly started reopening the file. Odd.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 12, 2023 Dec 12, 2023

Copy link to clipboard

Copied

LATEST

I've attached a sample file of one of our proof sheets. Once opened—with the first impression of the sample art selected—running the script will condense the artwork, copy it to the clipboard, undo the compression and resave it (this moves all the proofs for which plates have been ordered to the top of the folder index when arranged by "Date modified".

 

Until recently, that was it. The file would close and I could paste the art onto the template we use to submit plate orders to the plate manufacturer. Worked great. Now, it closes but then immediately reopens the file and I have to manually close it so that I can continue. 

 

Anyway, I took the file document.close part out of the script and made save and close the final step in the action that runs the script. That fixed it. It seems a little slower this way, but not enough to really bother me.

 

So I guess it's fixed, although I never figured out why the script (even if I ran it without the action) suddenly started reopening the file. Odd.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines