Loop through Layers
Hello,
I'm trying to ultimately Loop through Layers to see if they are visible(false) or locked(true) and if so skip or turn visible to true or turn locked to false.
I managed to do this with pathItems but I can't figure out why I can't do it with layers. Actually the check to see if it's visible isn't working either.
Anyway....when I run the script below on my work that has 1,000++ of pathItem it takes forever. So I wanted to add to the script to first loop through the layers to see if they are visible or locked to begin with. I tried using app.activeDocument.layers, but that doesn't seem to work and I don't understand why and I can't find any good tutorials to explain it. Any insight would be very much appreciated.
var doc = app.activeDocument;
var pathName = doc.pathItems;
function setColor(names) {
for (var i=0; i < pathName.length; i++) {
var currentLayer = pathName[i];
var pathNames = currentLayer.name;
var searchIndex = pathNames.indexOf(names);
if (searchIndex != -1 & currentLayer.locked == false & currentLayer.visible == true) {
currentLayer.selected = true; }
}
}
setColor("0");
