Highlighted

Identifying the order of the active layer

Participant ,
Aug 11, 2020

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")}

 

 

Topics

Actions and scripting

Views

104

Likes

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

Identifying the order of the active layer

Participant ,
Aug 11, 2020

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")}

 

 

Topics

Actions and scripting

Views

105

Likes

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
Aug 11, 2020 0
LEGEND ,
Aug 11, 2020

Copy link to clipboard

Copied

Are you familiar with JavaScript? 

Likes

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
Reply
Loading...
Aug 11, 2020 1
Participant ,
Aug 11, 2020

Copy link to clipboard

Copied

Minimum knowledge possible. Any suggestions friend?

Likes

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
Reply
Loading...
Aug 11, 2020 0
Adobe Community Professional ,
Aug 11, 2020

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.

Likes

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
Reply
Loading...
Aug 11, 2020 2
Participant ,
Aug 11, 2020

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")}

Likes

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
Reply
Loading...
Aug 11, 2020 1
LEGEND ,
Aug 11, 2020

Copy link to clipboard

Copied

Have you tested that piece of code yet? 

Likes

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
Reply
Loading...
Aug 11, 2020 1
Enthusiast ,
Aug 12, 2020

Copy link to clipboard

Copied

id != number in order

Likes

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
Reply
Loading...
Aug 12, 2020 1
LEGEND ,
Aug 12, 2020

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. 

Likes

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
Reply
Loading...
Aug 12, 2020 0
Enthusiast ,
Aug 12, 2020

Copy link to clipboard

Copied

 

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

 

 

Likes

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
Reply
Loading...
Aug 12, 2020 1
Adobe Community Professional ,
Aug 12, 2020

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

Likes

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
Reply
Loading...
Aug 12, 2020 1
Participant ,
Aug 12, 2020

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.

 
 

Likes

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
Reply
Loading...
Aug 12, 2020 0
Participant ,
Aug 12, 2020

Copy link to clipboard

Copied

Thank you jazz-y

Likes

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
Reply
Loading...
Aug 12, 2020 0
Participant ,
Aug 12, 2020

Copy link to clipboard

Copied

Thanks for suport Manan Joshi

 

Likes

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
Reply
Loading...
Aug 12, 2020 0
Adobe Community Professional ,
Aug 11, 2020

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

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

-Manan

Likes

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
Reply
Loading...
Aug 11, 2020 1