PS Script - Change Layer Color

This Is My First Post Here, So Hello Everyone,
Hope I Am Posting In The Right Section,
I Have A Photoshop File Which Looks Like Shown Above..
The Text 1 2 3 ...15 Are Different Layers..
And The Boxes Are Different Layers, Named i1 i2 i3 ...... i15
I Want To Write A Script That Will Change The Color Of Boxes (Actually This Is Legend Section For A Pie Chart)
I Want To Write Very Hard-Coded Script, Nothing Dynamic,
Like
layer[i1].color = #9f13a8
layer[i2].color = #520457
layer[i3].color = #cc626c
layer[i4].color = #aa5705
I Tried Searching Around, But Very Less Help Available On ps-script And Complicated Examples....
I Just Want Some Simple Lines, How To Easily Reference A Layer By Name And Change The Color (Forecolor, I Guess)
I Wrote This But It Does Not Works
var myDocument = app.activeDocument;
var myLayer;
myLayer=myDocument.artLayers.getByName("i1");
myLayer.color="#9f13a8";
I Don't Know If .artLayers Is Only For Text Layers Or Something.. I Found It In An Example...
Thanks

If you want to apply a pattern you can use scriptlistener to generate the code. It might be best to create the shape first by either drawing it or by using scriptlistener to generate the code, then use scriptlistener to generate code to change the fill pattern. This way you can use that code for any type of shape layer: oval, rectangle, etc. If you don't want a dialog box, you will have to find both the name and id number for the pattern used - again, this will show up using scriptlistener. If you want have a dialog box come up and be able to select which pattern you want to use, change the last line of the scriptlistener code to:
executeAction( idsetd, desc10, DialogModes.ALL );
But be sure to reset the dialog mode to No after that line. Here's an example of the code for changing a pattern:
#target photoshop
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( idcontentLayer, idOrdn, idTrgt );
    desc10.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T  " );
        var desc11 = new ActionDescriptor();
        var idPtrn = charIDToTypeID( "Ptrn" );
            var desc12 = new ActionDescriptor();
            var idNm = charIDToTypeID( "Nm  " );
            desc12.putString( idNm, """$$$/Presets/Patterns/Patterns_pat/TieDye=Tie Dye""" );//pattern name
            var idIdnt = charIDToTypeID( "Idnt" );
            desc12.putString( idIdnt, """1b29876b-58b7-11d4-b895-a898787104c1""" );//pattern ID number
        var idPtrn = charIDToTypeID( "Ptrn" );
        desc11.putObject( idPtrn, idPtrn, desc12 );
    var idpatternLayer = stringIDToTypeID( "patternLayer" );
    desc10.putObject( idT, idpatternLayer, desc11 );
executeAction( idsetd, desc10, DialogModes.ALL );//Change the NO to ALL
app.displayDialogs = DialogModes.NO;//Make sure you reset!!!

Similar Messages

  • Working with Edge Animate, how do you change layer colors and and names of layers?

    For many years, I have worked with Adobe Photoshop, and the ability to change layer color or the name of layers is quite easy. I have been reading around about how to do this with Edge, but, can't find any information on how I might be able to do this. Can you help?
    Thank you!
    LainKennedy

    Hi Darrell,
    Thank you for your answer. When I double click on the layer name, it opens for a second, then closes. I have tried to close the app, shut down my workstation, throw out the preferences, and, nothing seems to work. Am I doing something wrong?
    Thank you, again, for your timly answer. Really appreciate your help.
    Lain

  • Changing layer colors

    Can anyone help?  I am trying to change 2  color layers in a psd file and can't figure out how to do it...
    Note, I tried to attach the .psd file here but the upload manager wouldn't let me.

    Hi tried that but it won't open the dialogue.  Can I email the file to you since it wouldn't let me upload the psd?

  • Shouldn't this script change the color of a field ?

    if( this.rawValue == "1") { this.border.fill.color.value == "255,0,0"; }

    smde,
    I am not sure what you are trying to accomplish but I would discourage directly modifying the XML source.
    Typically a fill colour change is performed in response to an event such as a failed validation. In this case you would put your script in the validation event for the applicable object.
    Additionally, your script is not going to work because you are checking equality "==" rather than doing an assignment "=".
    this.border.fill.color.value = "225,0,0,";
    will change the fill colour to red.
    Steve

  • How to set layer color property via script?

    I'm looking for a way to set a layer's UI color property via script (see attached). Any help would be greatly appreciated!

    jrapczak2 wrote:
    Uhm.. wow. That's crazy complicated
    It is even more complicated to work with multi-selected layers.
    if( app.documents.length > 0 && versionCheck()  ){
         app.activeDocument.suspendHistory("Set Layer's Color", 'changeLayersColor()');
    function versionCheck()  { return app.version.match(/1[1|2]./) >= 11; };
    function changeLayersColor(){
         function setActiveLayerColor( color ) {
              var desc = new ActionDescriptor();
                   var ref = new ActionReference();
                   ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
              desc.putReference( charIDToTypeID('null'), ref );
                   var colorEnumDesc = new ActionDescriptor();
                   colorEnumDesc.putEnumerated( charIDToTypeID('Clr '), charIDToTypeID('Clr '), color );
              desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), colorEnumDesc );
              executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
         function getSelectedLayersIdx(){
                   var selectedLayers = new Array;
                   var ref = new ActionReference();
                   ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
                   var desc = executeActionGet(ref);
                   if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
                        desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
                         var c = desc.count
                         var selectedLayers = new Array();
                         for(var i=0;i<c;i++){
                             try{
                                  activeDocument.backgroundLayer;
                                  selectedLayers.push(  desc.getReference( i ).getIndex() );
                             }catch(e){
                                  selectedLayers.push(  desc.getReference( i ).getIndex()+1 );
                    }else{
                        var ref = new ActionReference();
                        ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
                        ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
                        try{
                             activeDocument.backgroundLayer;
                             selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
                        }catch(e){
                             selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
                   return selectedLayers;
         function makeActiveByIndex( idx, visible ){
              if( idx.constructor != Array ) idx = [ idx ];
              for( var i = 0; i < idx.length; i++ ){
                   var desc = new ActionDescriptor();
                   var ref = new ActionReference();
                   ref.putIndex(charIDToTypeID( "Lyr " ), idx[i] );
                   desc.putReference( charIDToTypeID( "null" ), ref );
                   if( i > 0 ) {
                        var idselectionModifier = stringIDToTypeID( "selectionModifier" );
                        var idselectionModifierType = stringIDToTypeID( "selectionModifierType" );
                        var idaddToSelection = stringIDToTypeID( "addToSelection" );
                        desc.putEnumerated( idselectionModifier, idselectionModifierType, idaddToSelection );
                   desc.putBoolean( charIDToTypeID( "MkVs" ), visible );
                   executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
         var colors = ['None','Red','Orange','Yellow','Green','Blue','Violet','Grey'];
         var colorIDs = [charIDToTypeID('None'),
                                  charIDToTypeID( "Rd  " ),
                                  charIDToTypeID( "Orng" ),
                                  charIDToTypeID( "Ylw " ),
                                  charIDToTypeID( "Grn " ),
                                  charIDToTypeID( "Bl  " ),
                                  charIDToTypeID( "Vlt " ),
                                  charIDToTypeID( "Gry " )];
         var dlg = new Window( 'dialog', 'Change Layer Color' );
         dlg.ddColors= dlg.add("dropdownlist", undefined,  colors);
         dlg.ddColors.preferredSize.width = 100;
         dlg.ddColors.items[0].selected = true;
         dlg.ok = dlg.add('button',undefined,'Ok');
         dlg.cancel = dlg.add('button',undefined,'Cancel');
         var results = dlg.show();
         if( results == 1 ){
              var selectedLayers =  getSelectedLayersIdx();
              for( var l=0;l<selectedLayers.length;l++ ){
                   makeActiveByIndex( selectedLayers[l], false );
                   setActiveLayerColor( colorIDs[dlg.ddColors.selection.index] );
              makeActiveByIndex( selectedLayers,false );

  • Is there a way to change the Layer Color Tag via Script?

    I tried to use the Script Listener to find the Event to change the Layer Color Tag but there were no commands recorded to my desktop. I have scoured the forums and the depths of Goooooo....ooogle and to no avail.
    I checked the API for an Art Layer and found no options to assign a Color Tag.
    I want to change the Color Tag From:
    To Color Tag Purple:
    Could anyone please help point me in the Right Direction?

    Just solved my own question:
    Photoshop was being weird so I had to change the color 2 times for the event to be recognized...idk why but it worked: heres the code:
    desc66.putReference( idnull, ref55 );
        var idT = charIDToTypeID( "T   " );
            var desc67 = new ActionDescriptor();
            var idClr = charIDToTypeID( "Clr " );
            var idClr = charIDToTypeID( "Clr " );
            var idVlt = charIDToTypeID( "Vlt " );
            desc67.putEnumerated( idClr, idClr, idVlt );
        var idLyr = charIDToTypeID( "Lyr " );
        desc66.putObject( idT, idLyr, desc67 );
    executeAction( idsetd, desc66, DialogModes.NO );

  • Is it possible to change the color of a layer of a Customs CSS from an External Style sheet?

    Hi,
    I have sucessfully link External .css  file to my HTML page and able to change the font size of the headlines and the paragraph.
    What I am not able to do is to ADD the color my Custom CSS from the External sheet.  I have difined the color attribute as a 'Advance'
    and gave it the same name "#bigwraper" that is has in my HTML file.
    Attached is the color outline of my 'Blank Layout' with colors?
    Thank you.
    Dreamer101.1

    Hi Murray,
    I am building a web site on which the entire content would be changed at least daily. The website would have similar design to www.Helium.com
    The page will have CCS layout boxes in which different content would  be pasted.
    To re-phrase my question:  I want to know how to change the color of a layer from an external style sheet?
    Because my home page 'Sidebar' and colors would be the same for all page, only the content of different pages would be different.  If I want to change a color of my web side pages, I need to learn how to do it in one spot through an External Style Sheet.
    I am amble to link my external style sheet and to change H1 tag and to give it different colors. But I was not sucess with change the color of a layer on which my content sits around.
    I took out the color from my HTML page and gave the same name to the layer in my External Style Sheet with the same color.
    Hope my question and the reason I was able to clarify.
    cheers,
    Dreamer101.1

  • I am trying to change the color of a background layer and it will not accept the color I want

    I am trying to change the color of a background layer and it will not accept the color I want

    If you want to get help you may have to provide a lot more details about what you are doing (which tools or commands do you use, what exactly happens when it fails, …)?

  • Is there a simple way to change the color of a new layer?

    I draw a box, which creates a new layer, but I cannot find a way to change the color of the layer. I can easilty create a box and change the color in Fireworks but this logic or funtionality evades me in Photoshop. Perhaps I'm using the wrong program to create graphics. Should I use Design or Illustrator instead?

    If you prefer using Fireworks, use Fireworks!
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • Can you layer a Microsoft shape onto an image in Photoshop and change the color???

    I'm using OS X Yosemite 10-10-1, Photoshop CC, 2014.2.1. I uploaded a shape from Word Office 2011 and layered it over my image. The symbol is blue and I want to change the color in Photoshop. I've tried but can't seem to figure out how it's done. The shape is blue.
    Thank you.

    Put the Word symbol on a new Word document.
    Save as  .pdf
    Bring into Photoshop and save as .psd. The area around the symbol will be clear.
    Drag symbol layer over an image
    Lock the clear area usng the symbol indicated by the red arrow shown above
    Choose your replacement color
    Edit > Fill with the Blending Mode set to Color
    Job done.

  • Changing mask colors or placing transparent text over another layer

    Hey. Looking for a little help here. Basically I have some video footage on one layer. I want to make a text mask that will go over the footage so that the footage can only be seen inside the letters. I was able to do this by creating an image mask and inserting the text into the HUD, however now the mask background around my letters is black and I need it to be white. Any thoughts for how to change the color of the mask from black to white while still leaving the lettering transparent so that the video footage is visible behind it? Also willing to try other techniques if you have thoughts. Thanks for your time,
    Eric

    Add a white rectangle shape to the group, put it at the bottom.

  • Can I cycle through and change the color overlay of certain layers by name using script?

    Can I cycle through and change the color overlay of certain layers by name using script?

    Sure. Ask in the scripting forum and refer to the scripting docs.
    Mylenium

  • Changing Text Color Through Scripting?

    Is it possible to change the color of a text field within a
    display icon through scripting ?
    Basically using a calc icon I want to display text within a
    display icon and change the text color as well. Ideally I would
    like to use authorware's RGB function to change the text colour.
    Any help greatly appreciated. Thanks in advance.

    "Mike P" <[email protected]> wrote in
    message
    news:fq5vdj$8jt$[email protected]..
    > Is it possible to change the color of a text field
    within a display icon
    > through scripting ?
    >
    > Basically using a calc icon I want to display text
    within a display icon
    > and
    > change the text color as well. Ideally I would like to
    use authorware's
    > RGB
    > function to change the text colour.
    No. You have two choices. The first is something like this:
    {varRed}{varBlue}{varGreen}
    the {varRed} text would be red
    {varBlue} would be blue
    {varGreen} would be green.
    Then:
    varRed := "This is some text"
    varBlue := varGreen := ""
    Your text would be red if Update Displayed Variables was
    checked on the
    icon.
    You can also use RTF Objects, which will allow you to set
    font color using
    named colors or hexadecimals.
    HTH;
    Amy

  • Setting the layer color property with javascript

    Is it possible to set a layer's color in the layers palette using javascript?
    By default everything shows up with no layer color but if you right click (ctrl-click) on a layer you have the option to change the color to Red, Orange, Yellow, etc.
    My question is can I do this with a script?
    I can lock a layer, change it's visibility and opacity, but I can't seem to find any reference to that particular property.
    Any help is appreciated.
    Thanks,
    Zara

    This will set the active layers colour....
    layerColour("Violet");
    function layerColour(colour) {
        switch (colour.toLocaleLowerCase()){
            case 'red': colour = 'Rd  '; break;
            case 'orange' : colour = 'Orng'; break;
            case 'yellow' : colour = 'Ylw '; break;
            case 'yellow' : colour = 'Ylw '; break;
            case 'green' : colour = 'Grn '; break;
            case 'blue' : colour = 'Bl  '; break;
            case 'violet' : colour = 'Vlt '; break;
            case 'gray' : colour = 'Gry '; break;
            case 'none' : colour = 'None'; break;
            default : colour = 'None'; break;
        var desc = new ActionDescriptor();
            var ref = new ActionReference();
            ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
        desc.putReference( charIDToTypeID('null'), ref );
            var desc2 = new ActionDescriptor();
            desc2.putEnumerated( charIDToTypeID('Clr '), charIDToTypeID('Clr '), charIDToTypeID(colour) );
        desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), desc2 );
        executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );

  • Changing the color of a selection to HEX

    Hi guys,
    i'm new to illustrator scripting (but not to javascript or programming).
    I have an AI file that has multiple layers. each layer has several items that are supposed to be of same color.
    I have an array of HEX values.
    I would like to loop over all items in a single layer, select them and change their color to some given HEX.
    Once that works, I will run on all HEX entries in array and save each variation in a separate PNG file.
    For the first part i wrote some script (see below), but i do not see any change in the file after i run the script. No errors and no change.
    I run the script once i select all items in a specific layer.
    Can you please advise what am i doing wrong?
    Thanks in advance!
    My code:
    function hexToRgb(hex) {
        var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
        return result ? {
            r: parseInt(result[1], 16),
            g: parseInt(result[2], 16),
            b: parseInt(result[3], 16)
        } : null;
    var fillRGBColor = function (pathItem, r, g, b){
        pathItem.fillColor.red = r;
        pathItem.fillColor.green = g;
        pathItem.fillColor.blue = b;
    var fillHexColor = function (pathItems, hex){
        var rgb = hexToRgb(hex);
        alert(rgb.r +","+rgb.g+","+rgb.b);
        fillRGBColor(pathItems, rgb.r, rgb.g, rgb.b);
    // check if a document is open in Illustrator.
    if( app.documents.length > 0)
              mySelection = app.activeDocument.selection;
              if (mySelection.length > 0)  {
                 for (var i=0; i<mySelection.length; i++) {
                      var currentObject = mySelection[i]; 
                      if(currentObject.typename != "CompoundPathItem" &&  
                                                                currentObject.typename != "GroupItem")  {
                             fillHexColor(currentObject, '#8F623B');
              } else {
                             alert("Nothing is selected.");
    } else {
              alert("No document Open.");

    Yup!
    my objects were in CMYK mode and not RGB. i changed the handling and everything started working fine.
    I have a different question now - how can i color TextFrame objects?
    I have a layer with some text on it and i want to generate a bunch of PNG files from that layer with text color changes.
    I see that the selected element is of type TextFrame, but it does not have a fillColor attribute.
    what controls text color?
    thanks in advance!

Maybe you are looking for

  • External hard drive for video editing

    I am looking for a reliable and fast external hard drive, which I can store my projects in and work off of. I use Final Cut Pro. PowerBook G4 17" I don't know if my mac has the eSATA or FW 800. Here are what I've been looking at so far: 500GB OWC Mer

  • Advantages of iWork over Open Office?

    I just began using iWork, which looks spare and elegant, as you'd expect from Apple. I'm not finding all the functionality I now use in LibreOffice, and I'm wondering what the advantages of using iWork are, versus using LibreOffice, or any of the oth

  • How to develop Dreameaver CC2014 CEP 5 extensions?

    Hi, I am reading about the new CEP for CC 2014, and oh it's very exciting. To think that i can write extensions in InDesign and Photoshop using the most up to date HTML5 methods...that's crazy. angular, jQuery...all the goodies. I'm struggling with u

  • Solaris Cluster and VMware Disk and SCSI Sharing Questions

    Hello folks, Does Solaris Clustering support the following? Oracle Solaris 11 Cluster support shared disk using VMware 5.1 RDM? Oracle  Solaris 11 Cluster using VMware SCSI Bus Sharing? (although VMware doesn't support this) Best, Dave

  • TS3297 Security questions are not mine

    Security questions are not mine