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

JavaScript to make Solid Color Layer

Engaged ,
Oct 02, 2016 Oct 02, 2016

Hello,

I'm rusty on my javaScript for Photoshop CC 2015. I'm trying to get JS to make a new solid color layer, but can't find how to do this.

Here's the code I have so far, but when it's run, it just makes a new blank layer above the default background layer:

#target photoshop

var srcDoc=app.activeDocument;

var allDocs = app.documents;

  var lengthDocs = allDocs.length;

 

  var  mySolidColor = new SolidColor();

  mySolidColor.rgb.red=255;

  mySolidColor.rgb. green=255;

  mySolidColor.rgb.blue=255;

 

  var solidFillLayer=srcDoc.artLayers.add(mySolidColor);


It's only an island if you look at it from the water.
TOPICS
Actions and scripting
2.4K
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

Community Expert , Oct 02, 2016 Oct 02, 2016

Hi soundman1963​,

you need a solid color layer? (And not a pixelbased colored layer?)

Try something like this:

var desc5 = new ActionDescriptor();

    var ref1 = new ActionReference();

    var idcontentLayer = stringIDToTypeID( "contentLayer" );

    ref1.putClass( idcontentLayer );

desc5.putReference( charIDToTypeID( "null" ), ref1 );

    var desc6 = new ActionDescriptor();

        var desc7 = new ActionDescriptor();

            var desc8 = new ActionDescriptor();

            desc8.putDouble( charIDToTypeI

...
Translate
Adobe
Community Expert ,
Oct 02, 2016 Oct 02, 2016
LATEST

Hi soundman1963​,

you need a solid color layer? (And not a pixelbased colored layer?)

Try something like this:

var desc5 = new ActionDescriptor();

    var ref1 = new ActionReference();

    var idcontentLayer = stringIDToTypeID( "contentLayer" );

    ref1.putClass( idcontentLayer );

desc5.putReference( charIDToTypeID( "null" ), ref1 );

    var desc6 = new ActionDescriptor();

        var desc7 = new ActionDescriptor();

            var desc8 = new ActionDescriptor();

            desc8.putDouble( charIDToTypeID( "Rd  " ), 255.000000 );

            desc8.putDouble( charIDToTypeID( "Grn " ), 0.000000 );

            desc8.putDouble( charIDToTypeID( "Bl  " ), 0.000000 );

        desc7.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), desc8 );

    desc6.putObject( charIDToTypeID( "Type" ), stringIDToTypeID( "solidColorLayer" ), desc7 );

desc5.putObject( charIDToTypeID( "Usng" ), idcontentLayer, desc6 );

executeAction( charIDToTypeID( "Mk  " ), desc5, DialogModes.NO );

If so, have fun

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