Copy link to clipboard
Copied
Hi again
Still rookie question I guess :S
I just try to create a solid fill layer.
The ScriptListener Code doesn't work :S
I can check if a layer is a solid fill
if (doc.activeLayer.kind == LayerKind.SOLIDFILL)
I found a way to change the color of an existing one...
(borrowed CodeListener code)
f
function setColorOfFillLayer( sColor ) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( stringIDToTypeID('contentLayer'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
var fillDesc = new ActionDescriptor();
var colorDesc = new ActionDescriptor();
colorDesc.putDouble( charIDToTypeID('Rd '), sColor.rgb.red );
colorDesc.putDouble( charIDToTypeID('Grn '), sColor.rgb.green );
colorDesc.putDouble( charIDToTypeID('Bl '), sColor.rgb.blue );
fillDesc.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), colorDesc );
desc.putObject( charIDToTypeID('T '), stringIDToTypeID('solidColorLayer'), fillDesc );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
}
But I'm unable to simply create a "solid fill layer"...
Thanks for help !
Have a nice day.
Vinz
I think I haven't done anything different, but the following works on CC 2018 (at least Mac):
...var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
function makeSolidColorLayer(r,g,b) {
var d1 = new ActionDescriptor();
var d2 = new ActionDescriptor();
var d3 = new ActionDescriptor();
var d4 = new ActionDescriptor();
var r1 = new ActionReference();
r1.putClass( s2t( "contentLayer" ));
d1.putReference( c2t( "null
Copy link to clipboard
Copied
#target photoshop;
var sc = new SolidColor();
sc.rgb.hexValue = "0000ff";
solidFill(sc);
function solidFill(colour) {
var ad = new ActionDescriptor();
var ar = new ActionReference();
var ad2 = new ActionDescriptor();
var ad3 = new ActionDescriptor();
var ad4 = new ActionDescriptor();
ar.putClass( stringIDToTypeID( "contentLayer" ));
ad.putReference( charIDToTypeID( "null" ), ar );
ad4.putDouble( charIDToTypeID( "Rd " ), colour.rgb.red );
ad4.putDouble( charIDToTypeID( "Grn " ), colour.rgb.green );
ad4.putDouble( charIDToTypeID( "Bl " ), colour.rgb.blue );
ad3.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), ad4 );
ad2.putObject( charIDToTypeID( "Type" ), stringIDToTypeID( "solidColorLayer" ), ad3 );
ad.putObject( charIDToTypeID( "Usng" ), stringIDToTypeID( "contentLayer" ), ad2 );
executeAction( charIDToTypeID( "Mk " ), ad, DialogModes.NO );
};
Copy link to clipboard
Copied
Thanks a lot
Unfortunately, I have a popup ""create' command is not available"...(I have CC2017)
II only changed the executeAction for a non silent mode...
function testMe() {
var sc = new SolidColor();
sc.rgb.hexValue = "0000ff";
solidFill(sc);
}
function solidFill(colour) {
var ad = new ActionDescriptor();
var ar = new ActionReference();
var ad2 = new ActionDescriptor();
var ad3 = new ActionDescriptor();
var ad4 = new ActionDescriptor();
ar.putClass( stringIDToTypeID( "contentLayer" ));
ad.putReference( charIDToTypeID( "null" ), ar );
ad4.putDouble( charIDToTypeID( "Rd " ), colour.rgb.red );
ad4.putDouble( charIDToTypeID( "Grn " ), colour.rgb.green );
ad4.putDouble( charIDToTypeID( "Bl " ), colour.rgb.blue );
ad3.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), ad4 );
ad2.putObject( charIDToTypeID( "Type" ), stringIDToTypeID( "solidColorLayer" ), ad3 );
ad.putObject( charIDToTypeID( "Usng" ), stringIDToTypeID( "contentLayer" ), ad2 );
try { executeAction( charIDToTypeID( "Mk " ), ad, DialogModes.NO ); } catch (e) { alert(e) }
}
Thanks
Copy link to clipboard
Copied
Sorry about that, I only have Photoshop CS6 (where it does work) so things must have changed.
I am sure someone with cc2017 will soon give you an answer.
Copy link to clipboard
Copied
I think I haven't done anything different, but the following works on CC 2018 (at least Mac):
var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
function makeSolidColorLayer(r,g,b) {
var d1 = new ActionDescriptor();
var d2 = new ActionDescriptor();
var d3 = new ActionDescriptor();
var d4 = new ActionDescriptor();
var r1 = new ActionReference();
r1.putClass( s2t( "contentLayer" ));
d1.putReference( c2t( "null" ), r1 );
d4.putDouble( s2t( "red" ), r);
d4.putDouble( c2t( "Grn " ), g);
d4.putDouble( s2t( "blue" ), b);
d3.putObject( s2t( "color" ), s2t( "RGBColor" ), d4 );
d2.putObject( s2t( "type" ), s2t( "solidColorLayer" ), d3 );
d1.putObject( s2t( "using" ), s2t( "contentLayer" ), d2 );
executeAction( s2t( "make" ), d1, DialogModes.NO );
}
// E.g.
makeSolidColorLayer(10,20,10);
Copy link to clipboard
Copied
inspection acado48882969 написал(а)
Unfortunately, I have a popup ""create' command is not available"...(I have CC2017)
II only changed the executeAction for a non silent mode...
Do you have any open document?
Copy link to clipboard
Copied
Hi,
My bad :S
Back at work, It works fine ...
Definitively an issue on my home workstation. (same config)
Thanks very very much for your help (and my apologies for this embarassing second issue !)
Real much appreciated !
Warmth and sun for everyone.
Copy link to clipboard
Copied
Yep ! I found my issue.
I'm working on channels, and when I select a channel mask in my function, the focus change and is not directly on a "layer", this gives the "cannot Create" issue... Didn't thought about it at first !
My bad ! Sorry guys...
Still a newby !
Copy link to clipboard
Copied
No problem 🙂
As a friendly advice (been there myself before), each time Photoshop pops up weird errors, it's likely because the otherwise correct action is applied to the wrong object.