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

Identifying the order of the active layer

Engaged ,
Aug 11, 2020 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!

 

 

TOPICS
Actions and scripting

Views

410

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
community guidelines

correct answers 1 Correct answer

Guide , Aug 12, 2020 Aug 12, 2020

 

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

 

 

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 11, 2020 Aug 11, 2020

Copy link to clipboard

Copied

Are you familiar with JavaScript? 

Votes

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
community guidelines
Engaged ,
Aug 11, 2020 Aug 11, 2020

Copy link to clipboard

Copied

Minimum knowledge possible. Any suggestions friend?

Votes

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
community guidelines
Community Expert ,
Aug 11, 2020 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.

Votes

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
community guidelines
Engaged ,
Aug 11, 2020 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")}

Votes

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
community guidelines
Community Expert ,
Aug 11, 2020 Aug 11, 2020

Copy link to clipboard

Copied

Have you tested that piece of code yet? 

Votes

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
community guidelines
Engaged ,
Aug 12, 2020 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.

 
 

Votes

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
community guidelines
Guide ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

id != number in order

Votes

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
community guidelines
Community Expert ,
Aug 12, 2020 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. 

Votes

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
community guidelines
Guide ,
Aug 12, 2020 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")}

 

 

Votes

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
community guidelines
Engaged ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

Thank you jazz-y

Votes

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
community guidelines
Community Expert ,
Aug 12, 2020 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

Votes

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
community guidelines
Engaged ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

LATEST

Thanks for suport Manan Joshi

 

Votes

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
community guidelines
Community Expert ,
Aug 11, 2020 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

Votes

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
community guidelines