Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Layer loop stops short?

$
0
0
#target illustrator
var doc = app.activeDocument;
var allLayers = doc.layers;
for (var i = 0; i < allLayers.length; i++) {    allLayers[i].locked = false;    if (allLayers[i].name == "Hypertext" || allLayers[i].name == "Taps") {        alert("I found the " + allLayers[i].name + " layer")    } else {        //alert("Not the right layer")        allLayers[i].remove();    }
}

 

Can anyone tell me why my loop is stopping short?

I am trying to delete ALL of the layers in the active document that are NOT named Hypertext or Taps.

There are 28 layers in my document (including the 2 specific layers I want to keep).

After I run the script that I wrote (see above script) it does in fact keep my two desired layers but it also doesn't delete all the other layers. I am left with 12 layers that need to be deleted still.

 

Anyone see what I am doing wrong?

 

Windows 7 64bit, CS4, JavaScript


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>