0

Not sure why this isn't working. I seem to have selected the layer that I want but the pathItems on that layer aren't being selected or changed.

var docRef = app.activeDocument;

var layerRef = docRef.layers;

for (i=0; i<docRef.layers.length; i++){
    if (layerRef[i].name === "Perflines"){

        var perfColor = new CMYKColor(100, 100, 0, 0);

        layerRef[i].pathItems.selected = true;

        layerRef[i].pathItems.strokeColor = perfColor;

        layerRef[i].pathItems.strokeWidth = 1;

        alert(layerRef[i].name);

        }
    }
popealope
  • 21
  • 1
  • 5

1 Answers1

2

PathItems is a collection and has no property selected.

see http://yearbookmachine.github.io/esdocs/#/Illustrator/PathItems

Also a single PathItem has no property selected either.

see http://yearbookmachine.github.io/esdocs/#/Illustrator/PathItem

You need to select your objects in a different way.

maybe this way (not tested)

var items = layer.pageItems;
for(var i = 0;i < items.length;i++){
  if(items[i] instanceOf PathItem){
    items[i].selected = true;
  }
}

see http://yearbookmachine.github.io/esdocs/#/Illustrator/PageItem

fabianmoronzirfas
  • 4,091
  • 4
  • 24
  • 41