setting layer color using index property

Participant ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

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

Views

1.0K

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

correct answers 1 Correct Answer

Adobe Community Professional , May 19, 2021 May 19, 2021
Just checked again (CS6 and CC2020). Only the active layer changes.

Likes

Translate

Translate
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

layerColourIndex(1)

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
community guidelines
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

The color and name can only be changed for the active layer. Feature of Photoshop (its Actions) since ancient times.

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
community guidelines
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

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)

 

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
community guidelines
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

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

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
community guidelines
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

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

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
community guidelines
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

Are you saying that everything works in your version? It's a shame I can't verify this.

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
community guidelines
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

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?

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
community guidelines
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

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.

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
community guidelines
Adobe Community Professional ,
May 19, 2021 May 19, 2021

Copy link to clipboard

Copied

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.

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
community guidelines
Participant ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

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. 

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