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

How to select multiple layers in photoshop through a script

Explorer ,
Sep 23, 2015 Sep 23, 2015

Is there a way to select multiple layers in Photoshop through a script without using script listener? I am

looking everywhere in the API but i am not able to find anything. Maybe i am just not looking right, please help!

TOPICS
Actions and scripting
1.8K
Translate
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

Community Expert , Sep 23, 2015 Sep 23, 2015

Selecting multiple layers requires action manager code. the DOM can't do it, and is slower anyway. If using scriptlistener works, that's what you should go with.

Translate
Adobe
Community Expert ,
Sep 23, 2015 Sep 23, 2015

Do you want to get the selected layers that have all ready been selected, or do you want the script to select multiple layers that you call out in your script? Or do you just want to put various layers into an array one at a time for later use, as in a loop?

Translate
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
Explorer ,
Sep 23, 2015 Sep 23, 2015

was wondering if there is a method or property of an artlayer which refers to it being selected Kind of like having them both be active layers. I need the script itself to select 2 layers and then align them on their respective top corners. I know i this can be done via scriptlistener and it has been my solution till now.

Translate
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
Community Expert ,
Sep 23, 2015 Sep 23, 2015

Selecting multiple layers requires action manager code. the DOM can't do it, and is slower anyway. If using scriptlistener works, that's what you should go with.

Translate
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
Explorer ,
Sep 23, 2015 Sep 23, 2015

Oh wow, i'm unsure why, but i was under the impression that that the DOM would run faster. Alright then, Thanks a lot!

Translate
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
Community Expert ,
Sep 23, 2015 Sep 23, 2015

No, AM code runs faster - odd, as it seems like it would be the other way with more lines of code.

Translate
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
Advisor ,
Sep 23, 2015 Sep 23, 2015

it would be the other way with more lines of code.

The main reason the DOM is slower is because you have to use fairly heavy objects like Document and Layer.  And their properties are not cached. This means that every time you access a property, it ends up making AM code in C/C++. This can get expensive really quickly.

Also, I have Stdlib.selectLayers(doc, layers, append)  in xtools/xlib/stdlib.js. It has the necessary AM code at the bottom.

Translate
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
Explorer ,
Sep 24, 2015 Sep 24, 2015
LATEST

Thanks for the explanation!

Translate
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