Copy link to clipboard
Copied
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!
if(app.activeDocument.layers[app.activeDocument.layers.length- 3] == app.activeDocument.activeLayer) {alert ("OK!")} else {alert ("false")}
Copy link to clipboard
Copied
Are you familiar with JavaScript?
Copy link to clipboard
Copied
Minimum knowledge possible. Any suggestions friend?
Copy link to clipboard
Copied
You can't accomplish that task using conditional actions which has limited set of conditions but not one that you need.
Copy link to clipboard
Copied
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")}
Copy link to clipboard
Copied
Have you tested that piece of code yet?
Copy link to clipboard
Copied
Hi c.pfaffenbichler I tested it, it worked fine. I had to use a script loop, but it would be necessary to add an extra function only in order 3 layer. Obtaining the ID of this layer I achieved my goal.
Copy link to clipboard
Copied
id != number in order
Copy link to clipboard
Copied
Yeah, at least in AM code the itemIndex gives the position in the stack while the identifier is a unique number.
Copy link to clipboard
Copied
if(app.activeDocument.layers[app.activeDocument.layers.length- 3] == app.activeDocument.activeLayer) {alert ("OK!")} else {alert ("false")}
Copy link to clipboard
Copied
Thank you jazz-y
Copy link to clipboard
Copied
I don't think AM code would be needed, like jazz-y pointed we can reliably use the layers array. I also used the same approach in the discussion i mentioned below. Everything seemed to work fine the last time i checked. Do you see any cases that would be missed without AM
-Manan
Copy link to clipboard
Copied
Thanks for suport Manan Joshi
Copy link to clipboard
Copied
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
-Manan