Skip to main content
Shulipa Bernad
Inspiring
August 11, 2020
Answered

Identifying the order of the active layer

  • August 11, 2020
  • 3 replies
  • 784 views

Good afternoon everyone!
If the active layer is the 3rd in order, then do something.
It would be something I'm looking for. Thank you!

 

 

This topic has been closed for replies.
Correct answer jazz-y

Yeah, at least in AM code the itemIndex gives the position in the stack while the identifier is a unique number. 


 

if(app.activeDocument.layers[app.activeDocument.layers.length- 3] == app.activeDocument.activeLayer) {alert ("OK!")} else {alert ("false")}

 

 

3 replies

Community Expert
August 11, 2020

See the following discussion, it will give you an idea on how to manipulate the layer order. It has code snippet for handling cases of layer groups as well

https://community.adobe.com/t5/photoshop/how-do-i-reverse-this-layers-naming-loop/td-p/11280626?page=1

-Manan

-Manan
Bojan Živković11378569
Community Expert
Community Expert
August 11, 2020

You can't accomplish that task using conditional actions which has limited set of conditions but not one that you need.

Shulipa Bernad
Inspiring
August 11, 2020

It is a pity that I cannot achieve such conditions. I am grateful for your attention.

I have achieved this so far: I think that would be enough.

if(app.activeDocument.activeLayer.id == 3){alert ("OK!")} else{alert ("false")}

c.pfaffenbichler
Community Expert
Community Expert
August 12, 2020

Have you tested that piece of code yet? 

c.pfaffenbichler
Community Expert
Community Expert
August 11, 2020

Are you familiar with JavaScript? 

Shulipa Bernad
Inspiring
August 11, 2020

Minimum knowledge possible. Any suggestions friend?