Copy link to clipboard
Copied
Why doesn't it? It deletes all but one hidden item on the targeted layer then errors here: "if (bkItem.hidden == true){" with "no such element"'.
var aDoc = app.activeDocument;
var bkItem = aDoc.layers["BACK TEXT"].pageItems;
var bkCnt = bkItem.length;//# of items in "BACK TEXT"
var a;//counter
for (a=0; a<bkCnt; a++){
if (bkItem.hidden == true){
bkItem.remove();
}
}
loop backwards
Copy link to clipboard
Copied
loop backwards
Copy link to clipboard
Copied
Thanks, pixxxel schubser​
This worked for me. The other key was adding a "=" to the if statement (a = bkCnt - 1; a >= 0; a--).
var aDoc = app.activeDocument;
var bkItem = aDoc.layers["BACK TEXT"].pageItems;
var bkCnt = bkItem.length;//# of items in "BACK TEXT"
var a;//counter
for (a = bkCnt - 1; a >= 0; a--){
if(bkItem.hidden == true){
bkItem.locked = false;
bkItem.remove();
}
}
Copy link to clipboard
Copied
Yes, because of pageItems[0] is the first pageItem in the "object array".
This also should also work: a> -1