4 Replies Latest reply on Jul 6, 2013 4:56 AM by pixxxel schubser

    Create Layer with BG Color

    StrongBeaver Level 3

      function layer() {


      Application.backgroundColor (blue = 34, green = 12, red = 1)






      I want to create a NewLayer, with a specific background color, the code above is not working.

        • 1. Re: Create Layer with BG Color
          Michael L Hale Level 5

          You really need to read the scripting guide.


          Application is a Photoshop Class. To reference that class you use app. So the first line in the function should be app.activeDocument. Even then that line does not do anything except return a document object. If you do not store the returned object in a variable you might as well delete that line.


          app.backgroundColor is an app property, not a method. So the () are not used. That property either returns a SolidColor object that is the current background color or you can assign it a new color something like this


          var myColor = new SolidColor();

          myColor.rgb.red = 1;

          myColor.rgb.green = 12;

          myColor.rgb.blue - 34;

          app.backgroundColor = myColor;


          But that does not create a new layer and I am not sure what kind of layer you want. Do you want to create a new artLayer then fill it with your color or do you want to create a new SolidFill adjustment layer using that color.


          To create a new artLayer you do something like




          To create a new adjustment layer you would need to use Action Manager( scriptlistener ).

          • 2. Re: Create Layer with BG Color
            pixxxel schubser MVP & Adobe Community Professional


            a layer has not a background color. And your code is fully wrong. Search in the OMV for the properties of document and layers.



            // http://forums.adobe.com/thread/1248703?tstart=0
            // LayerFillWithDefinedColor.jsx
            // regards pixxxelschubser
            // define your color
            aColor = new SolidColor();
            aColor.rgb.red = 1;
            aColor.rgb.green = 12;
            aColor.rgb.blue = 34;
            // define your document
            var aDoc = activeDocument;
            // fill the active layer, but be sure, this is an artLayer !
            aDoc.selection.fill( aColor);
            // add a new layer
            var aLayer = aDoc.artLayers.add();
            // and fill again
            aDoc.selection.fill( aColor);


            Have fun




            I was too slow. And what Michael L Hale said.


            • 3. Re: Create Layer with BG Color
              StrongBeaver Level 3

              I will review the scripting guide.  The script posted, has cleared up a little for me, thanks

              • 4. Re: Create Layer with BG Color
                pixxxel schubser MVP & Adobe Community Professional

                I think your behavior is hardly fair.

                Why you not marks the correct answers as helpful or correct?