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

Changing Layer Color

Enthusiast ,
Nov 11, 2013 Nov 11, 2013

Hi, here's a script which changes the layer's color (the 'eye' icon) to blue:

function setCurrentLayerBlue() {

  function cTID(s) { return app.charIDToTypeID(s); };

  function sTID(s) { return app.stringIDToTypeID(s); };

    var desc5 = new ActionDescriptor();

        var ref3 = new ActionReference();

        ref3.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );

    desc5.putReference( cTID('null'), ref3 );

        var desc6 = new ActionDescriptor();

        desc6.putEnumerated( cTID('Clr '), cTID('Clr '), cTID('Bl  ') );

    desc5.putObject( cTID('T   '), cTID('Lyr '), desc6 );

    executeAction( cTID('setd'), desc5, DialogModes.NO );

};

setCurrentLayerBlue();

and it works fine. But I can't get some of the other colors to work, such as Orange. I switched up the 'Blue' to 'Orange' and 'Blu' to "Orng' so I was hoping it would work but it isn't:

function setCurrentLayerOrange() {

  function cTID(s) { return app.charIDToTypeID(s); };

  function sTID(s) { return app.stringIDToTypeID(s); };

    var desc5 = new ActionDescriptor();

        var ref3 = new ActionReference();

        ref3.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );

    desc5.putReference( cTID('null'), ref3 );

        var desc6 = new ActionDescriptor();

        desc6.putEnumerated( cTID('Clr '), cTID('Clr '), cTID('Orng  ') );

    desc5.putObject( cTID('T   '), cTID('Lyr '), desc6 );

    executeAction( cTID('setd'), desc5, DialogModes.NO );

};

setCurrentLayerOrange();

TOPICS
Actions and scripting
769
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
Adobe
Community Expert ,
Nov 11, 2013 Nov 11, 2013

Did you run scriptListener for each color, just to get the descriptor name?  Guessing is like trying to pick a safe combo.

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
Enthusiast ,
Nov 11, 2013 Nov 11, 2013

geez I didn't even think of that.. how could I forget... I'll try it and report back..

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
Enthusiast ,
Nov 11, 2013 Nov 11, 2013

worked fine... don't know why I didn't think of that in the first place..

here's another script which used to change the layer color to a darker green than the standard green:

function setCurrentLayerDarkGreen() {

  function cTID(s) { return app.charIDToTypeID(s); };

  function sTID(s) { return app.stringIDToTypeID(s); };

    var desc5 = new ActionDescriptor();

        var ref3 = new ActionReference();

        ref3.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );

    desc5.putReference( cTID('null'), ref3 );

        var desc6 = new ActionDescriptor();

        desc6.putEnumerated( cTID('Clr '), cTID('Clr '), cTID('Gr  ') );

    desc5.putObject( cTID('T   '), cTID('Lyr '), desc6 );

    executeAction( cTID('setd'), desc5, DialogModes.NO );

};

setCurrentLayerDarkGreen();

..and it actually worked - it changed it to a deep green which isn't available as a standard color. But for some reason it won't work now.

Having said that, could there be a way to change the layer colors to other colors which aren't in the menu? (Pink, brown, or any other color we can think of) ?

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
Guru ,
Nov 11, 2013 Nov 11, 2013

..and it actually worked - it changed it to a deep green which isn't available as a standard color. But for some reason it won't work now.

It doesn't work for me. In fact if the layer already has a color this will set the color to none, removing the existing layer color.

Even if it did work I wouldn't recommend tying to do something that is not supported by the GUI. I think it might cause problems to have unexpected colors in the layer descriptor.

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
Enthusiast ,
Nov 11, 2013 Nov 11, 2013
LATEST

yeah it used to work - I was fascinated when I could change the color to a deep green - I always thought we were restricted to the 7 default colors (red blue yellow green violet orange gray). I don't know what went wrong though... it may have had something to do with an earlier version of Photoshop but it won't run on a more recent version. Ah well, not a big deal

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