Copy link to clipboard
Copied
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.
1 Correct answer
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
Explore related tutorials & articles
Copy link to clipboard
Copied
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

