How to update Solid Color adjustment layer color using Photoshop scripting?
Hi everyone,
Mission:
Fix a script where the solid color adjustment layer is selected (or created) and allows the user to pick a color from either a color picker functionality or the adjustment layer settings per se.
Is it possible to prompt the user to select a new color using the color picker or any other way?
In my script i managed to make something similar where the script will edit a normal layer and ask the user to:
- color pick a color
- then click ok = Layer fills with this color
- If user wants to change color, a new prompt comes up and allows user to edit color
- If user clicks ok again = Layer fills with new color
This works fine, but with a normal layer.
I ahvent been able to make this work but using a Solid Color adjustment layer instead, is it possible?
Reason: Currently, with the normal layer fill with new color functionality, photoshop needs to refresh the document for a second in order for the user to see the new color selected from the color picker before it asks the user if color is ok to continue the process.
I would like this to be a solid color layer instead, so that we can see how the color looks while choosing different colors directly in the color picker. Functionality i see only happens when editing a Solid Color adjustment layer.
I hope this does make sense!
Here are 2 functions i had but do not work.
I believe its not editing the soldid color layer properly?
function updateColorFillLayer(doc, colorFillLayer, fillColor) {
if (colorFillLayer.kind === LayerKind.SOLIDFILL) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID('AdjL'), colorFillLayer.id);
desc.putReference(charIDToTypeID('null'), ref);
var colorDesc = new ActionDescriptor();
colorDesc.putDouble(charIDToTypeID('Rd '), fillColor.rgb.red);
colorDesc.putDouble(charIDToTypeID('Grn '), fillColor.rgb.green);
colorDesc.putDouble(charIDToTypeID('Bl '), fillColor.rgb.blue);
desc.putObject(charIDToTypeID('T '), charIDToTypeID('SoCo'), colorDesc);
try {
executeAction(charIDToTypeID('setd'), desc, DialogModes.NO);
} catch (e) {
alert("Error: " + e.message);
}
} else {
alert("The specified layer is not a Solid Color adjustment layer.");
}
}
function updateColorFillLayer(doc, colorFillLayer) {
if (colorFillLayer.kind === LayerKind.SOLIDFILL) {
doc.activeLayer = colorFillLayer;
var idAdjs = charIDToTypeID("Adjs");
executeAction(idAdjs, undefined, DialogModes.ALL);
} else {
alert("The specified layer is not a Solid Color adjustment layer.");
}
}
