Skip to main content
Known Participant
May 5, 2016
Answered

Setting color and other attributes to path items on existing layer in doc.

  • May 5, 2016
  • 1 reply
  • 534 views

I want to set stroke color(existing spot swatch) and other attributes like overprint and stroke width to path items on a target layer("DIE") in the active document. What I have already sets what I want to all existing path items on all layers. I have tried ways to index the target layer "DIE" but can not seem to get it to work.

if(app.documents.length > 0 &&  app.activeDocument.pathItems.length > 0) {

   

    var doc = app.activeDocument;

   

   

    for (var i = 0; i < doc.pathItems.length; i++){

        plotSet = doc.pathItems;

        plotSet.filled = false;

        plotSet.stroked = true;

        plotSet.strokeWidth = 2;

        plotSet.strokeOverprint = true;

        plotSet.strokeColor = doc.swatches["PLOT"] .color;

        }

    }

This topic has been closed for replies.
Correct answer Ten A

Here is a sample code rewrited your script:

if(app.activeDocument.layers.getByName("DIE").pathItems.length > 0) {

  

    var tgt = app.activeDocument.getByName("DIE");

  

  

    for (var i = 0; i < tgt.pathItems.length; i++){

        plotSet = tgt.pathItems;

        plotSet.filled = false;

        plotSet.stroked = true;

        plotSet.strokeWidth = 2;

        plotSet.strokeOverprint = true;

        plotSet.strokeColor = doc.swatches.getByName("PLOT") .color;

        }

    }

1 reply

Ten A
Ten ACorrect answer
Community Expert
May 6, 2016

Here is a sample code rewrited your script:

if(app.activeDocument.layers.getByName("DIE").pathItems.length > 0) {

  

    var tgt = app.activeDocument.getByName("DIE");

  

  

    for (var i = 0; i < tgt.pathItems.length; i++){

        plotSet = tgt.pathItems;

        plotSet.filled = false;

        plotSet.stroked = true;

        plotSet.strokeWidth = 2;

        plotSet.strokeOverprint = true;

        plotSet.strokeColor = doc.swatches.getByName("PLOT") .color;

        }

    }