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

setting layer color using index property

Contributor ,
May 19, 2021 May 19, 2021

Could someone please tell me why this function wont work.... 

 

I can set other properties like layer visibility using a putIndex but not color??

 

 

function layerColourIndex(index) {  
 function c2t(s) {return charIDToTypeID(s)}
        var r1 = new ActionReference();  
               var d2 = new ActionDescriptor();  
                   var d1 = new ActionDescriptor();  
           r1.putIndex(c2t('Lyr '), index)
        d2.putEnumerated( c2t('Clr '), c2t('Clr '), c2t('None') );  
         d1.putReference( c2t('null'), r1 );  
       d1.putObject( c2t('T   '), c2t('Lyr '), d2 );  
    executeAction( c2t('setd'), d1, DialogModes.NO );  
};  
TOPICS
Actions and scripting
1.7K
Translate
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

People's Champ , May 19, 2021 May 19, 2021

Just checked again (CS6 and CC2020). Only the active layer changes.

Translate
Adobe
LEGEND ,
May 19, 2021 May 19, 2021
layerColourIndex(1)
Translate
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
People's Champ ,
May 19, 2021 May 19, 2021
The color and name can only be changed for the active layer. Feature of Photoshop (its Actions) since ancient times.
Translate
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
LEGEND ,
May 19, 2021 May 19, 2021

No, it works. Make document, duplicate layer few times, set all to some color, then select one which index is not in brackets of function caller. One's going to be uncoloured. Change number to confirm it.

The same for changing a name by index of unselected layer (that works too using Identifier with its id):

 

sTT = stringIDToTypeID;

(ref = new ActionReference()).putIndex(sTT('layer'), 1);
(dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref);
(dsc2 = new ActionDescriptor()).putString(sTT('name'), 'Hello!')
dsc1.putObject(sTT('to'), sTT('layer'), dsc2)
executeAction(sTT('set'), dsc1)

 

Translate
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
People's Champ ,
May 19, 2021 May 19, 2021

Just checked again (CS6 and CC2020). Only the active layer changes.

Translate
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
LEGEND ,
May 19, 2021 May 19, 2021

Mine was updated few days ago to 22.4.0 and today again to 22.4.1

Translate
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
People's Champ ,
May 19, 2021 May 19, 2021
Are you saying that everything works in your version? It's a shame I can't verify this.
Translate
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
LEGEND ,
May 19, 2021 May 19, 2021

I thought it does not work, as it never worked, fortunately thanks to this thread I found it finally works! Why can not you verify it while being ACP? Do you have some reasons for?

Translate
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
People's Champ ,
May 19, 2021 May 19, 2021
quote

I thought it does not work, as it never worked, fortunately thanks to this thread I found it finally works!


By Kukurykus

 

understood nothing : )

 

quote

Why can't you verify it if you're ACP? Perhaps you don't want to use 2021 release for some reason.


By Kukurykus

 

The new photoshop doesn't meet my system requirements. It just won't install.

Translate
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
LEGEND ,
May 19, 2021 May 19, 2021

That was my guess you may have too slow computer. Regarding first sentence I mean that I was aware we can't use in some cases Index to for ex. select a layer. Now I know it's changed.

Translate
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
Contributor ,
May 20, 2021 May 20, 2021
LATEST

Thank you both for your help, i didnt think of the version. 

 

I can verify it works on machine with 22.4.0 release and not on machine with 20.0.1 release. 

 

Havent updated as found new version very buggy. 

Translate
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