Copy link to clipboard
Copied
Hi all,
How do I select Item(s) in specific layer name
my code is
var layer=app.activeDocument.layers.everyItem().getElements("Info Layer");
can any one correct this, help will be appreciate
Thanks
Steve
Hi Steve,
Please try the below JS code, I just alernate the vandy method.
var myDoc = app.activeDocument;
var mylayer = myDoc.layers.itemByName("Layer 2");
for (var i=0; i <mylayer.allPageItems.length; i++){
mylayer.allPageItems.select();
}
thx,
csm_phil
Copy link to clipboard
Copied
myObject = app.documents[0].pageItems;
for (var i=0; i <myObject.length; i++)
{
if(myObject.itemLayer.name=="Info Layer")
{
myObject.select();
}
}
Vandy
Copy link to clipboard
Copied
Hi Steve & Vandy
No need to do a loop
Turn all Items yellow
app.activeDocument.layers.itemByName("Layer 1").pageItems.everyItem().fillColor = "Yellow"
Get Elements
myLayersItems = app.activeDocument.layers.itemByName("Layer 1").pageItems.everyItem().getElements()
Trevor
Copy link to clipboard
Copied
HI Trevor,
I have a doubt with the below js lines, If steve want to move the particular layer page items. In this case the below lines not working, So we have to loop it? Because he request to select the particular layer page items. so that, vandy loop the page items right!
Turn all Items yellow
app.activeDocument.layers.itemByName("Layer 1").pageItems.everyItem().fillColor = "Yellow"
Get Elements
myLayersItems = app.activeDocument.layers.itemByName("Layer 1").pageItems.everyItem().getElements()
thx,
csm_phil
Copy link to clipboard
Copied
Sorry Phil, I don't agree with you on this.
There is very rarely a case for "Selecting" an object,
To move the all the items to another layer one would just use
app.activeDocument.layers.itemByName("Layer 1").pageItems.everyItem().move(app.activeDocument.layers.itemByName("Layer 2"))
Trevor
Copy link to clipboard
Copied
Let's just clarify that Trevor's examples work only if the active document has layers with the exact names he's using in his sample code.
Dave
Copy link to clipboard
Copied
But with a limited amount of imagination it can be quite easily adapted
Copy link to clipboard
Copied
Hi Steve,
Please try the below JS code, I just alernate the vandy method.
var myDoc = app.activeDocument;
var mylayer = myDoc.layers.itemByName("Layer 2");
for (var i=0; i <mylayer.allPageItems.length; i++){
mylayer.allPageItems.select();
}
thx,
csm_phil