• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Select item(s) in layer

Community Beginner ,
Apr 10, 2014 Apr 10, 2014

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

TOPICS
Scripting

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Apr 10, 2014 Apr 10, 2014

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

Votes

Translate

Translate
Enthusiast ,
Apr 10, 2014 Apr 10, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 10, 2014 Apr 10, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 11, 2014 Apr 11, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 11, 2014 Apr 11, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 11, 2014 Apr 11, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 11, 2014 Apr 11, 2014

Copy link to clipboard

Copied

LATEST

But with a limited amount of imagination it can be quite easily adapted

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 10, 2014 Apr 10, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines