Skip to main content
Babymac08
Known Participant
December 14, 2016
Answered

Pause or Wait Between Commands...

  • December 14, 2016
  • 11 replies
  • 4361 views

The below is a portion of a larger script I have... What I'm wanting to do is place a Pause/Wait/Sleep (whichever is appropriate) command to wait on the item to finish printing before proceeding to the next section...

I've added the sleep function... but it doesn't appear to be working or is not understanding what I'm wanting it to do...

Any Ideas

//Print

var storeUserInteract = userInteractionLevel;

var d                 = activeDocument;

var jbOpts            = new PrintJobOptions();

var opts              = new PrintOptions();

opts.printPreset      = "JEFF_HP";

opts.jobOptions       = jbOpts;

userInteractionLevel  = UserInteractionLevel.DONTDISPLAYALERTS;

d.print(opts);

userInteractionLevel = storeUserInteract;

$.sleep (10000);

//Through Cut Backward

function wrapper()

{

     var docRef = app.activeDocument;

     var layers = docRef.layers;

     var artLayer = layers["Artwork"];

     var thruCutLayer = layers["Through Cut"];

   

     function bringThruCutForward()

     {

          thruCutLayer.zOrder(ZOrderMethod.BRINGTOFRONT);

     }

     function sendThruCutBackward()

     {

          thruCutLayer.zOrder(ZOrderMethod.SENDTOBACK);

     }

     sendThruCutBackward();

}

wrapper();

This topic has been closed for replies.
Correct answer Disposition_Dev

Ok. I thought you meant that " - Proof" was somehow being added to the beginning of the string which just didn't make any sense.

So your resulting filename is "my_placed_image.pdf"?

try this:

 

saveAsPdf(

     '~/Desktop/Illustrator Hot Folder/Reveal Zund Marks/OUT',

     activeDocument.placedItems[0].file.name,

     'Dynagraphics PDF - Flat - Layers'

);

function saveAsPdf(targFoldPath, targFileName, pdfPresName)

{

     var destFolder = new Folder (targFoldPath);

     var pdfOpts = new PDFSaveOptions();

     pdfOpts.pDFPreset = pdfPresName;

     var targFile = new File(destFolder + "/" + targFileName + " - Proof");

     app.activeDocument.saveAs(targFile, pdfOpts);

}

11 replies

o-marat
Inspiring
December 15, 2016

I think you don't need $.sleep in this case. I think in this snippet all actions will performed in sequence, after the previous steps will completed.

New for exemple, this code is executed sequentially:

//@target illustrator

// print to first file

var pres = 'JEFF_HP';

prnt('test1', pres);

// any another actions

wrapper();

redraw(); // if you whant to redraw the screen

// print to second file or make another actions

prnt('test2', pres);

function wrapper(){ 

    var docRef = app.activeDocument;

    var layers = docRef.layers;

    var artLayer = layers["Artwork"];

    var thruCutLayer = layers["Through Cut"];  

    function bringThruCutForward()     {

        thruCutLayer.zOrder(ZOrderMethod.BRINGTOFRONT);

    }  

    function sendThruCutBackward()     {

        thruCutLayer.zOrder(ZOrderMethod.SENDTOBACK);

    }

    sendThruCutBackward();

}

function prnt(fileName, printPresetName){

    var storeUserInteract = userInteractionLevel; 

    var d                 = activeDocument; 

    var filePath          = '/d/' + fileName + '.ps'

    var jbOpts            = new PrintJobOptions(); 

    var opts              = new PrintOptions(); 

    opts.printPreset      = "printPresetName"; 

    opts.jobOptions       = jbOpts; 

    jbOpts.file           = new File(filePath); 

    userInteractionLevel  = UserInteractionLevel.DONTDISPLAYALERTS; 

    d.print(opts); 

    userInteractionLevel = storeUserInteract;  

}