Skip to main content
Known Participant
September 23, 2015
Answered

How to select multiple layers in photoshop through a script

  • September 23, 2015
  • 1 reply
  • 1794 views

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!

This topic has been closed for replies.
Correct answer Chuck Uebele

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.

1 reply

Chuck Uebele
Community Expert
Community Expert
September 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?

robyAuthor
Known Participant
September 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.

Inspiring
September 23, 2015

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


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.