Set the fill colour of a vector shape?
Is it possible to set the fill colour and/or stroke colour of a vector shape in the currently selected layer with a script?
I'd use it in a similar way to the one I had help with before at this forum, by using a colour copied previously to the clipboard (in RGB Hex format) and applying that colour to the vector shape.
Here's the script I'm using to grab the colour from the clipboard and use when adding the colour overlay layer style, in case it helps understanding what I want to achieve with the new script:
set colourFromClipboard to the clipboard
tell application id "com.adobe.Photoshop"
set docRef to the current document
try
tell docRef
do javascript "var c = new SolidColor();
c.rgb.hexValue = " & quoted form of colourFromClipboard & "
app.activeDocument.suspendHistory('TMP', 'aaa()');
executeAction( charIDToTypeID( 'undo' ), undefined, DialogModes.NO );
executeAction( charIDToTypeID( 'PaFX' ), undefined, DialogModes.NO );
function aaa()
{
app.activeDocument.artLayers.add();
// =======================================================
// =======================================================
var idsetd = charIDToTypeID( 'setd' );
var desc9 = new ActionDescriptor();
var idnull = charIDToTypeID( 'null' );
var ref1 = new ActionReference();
var idPrpr = charIDToTypeID( 'Prpr' );
var idLefx = charIDToTypeID( 'Lefx' );
ref1.putProperty( idPrpr, idLefx );
var idLyr = charIDToTypeID( 'Lyr ' );
var idOrdn = charIDToTypeID( 'Ordn' );
var idTrgt = charIDToTypeID( 'Trgt' );
ref1.putEnumerated( idLyr, idOrdn, idTrgt );
desc9.putReference( idnull, ref1 );
var idT = charIDToTypeID( 'T ' );
var desc10 = new ActionDescriptor();
var idScl = charIDToTypeID( 'Scl ' );
var idPrc = charIDToTypeID( '#Prc' );
desc10.putUnitDouble( idScl, idPrc, 100.000000 );
var idSoFi = charIDToTypeID( 'SoFi' );
var desc11 = new ActionDescriptor();
var idenab = charIDToTypeID( 'enab' );
desc11.putBoolean( idenab, true );
var idpresent = stringIDToTypeID( 'present' );
desc11.putBoolean( idpresent, true );
var idshowInDialog = stringIDToTypeID( 'showInDialog' );
desc11.putBoolean( idshowInDialog, true );
var idMd = charIDToTypeID( 'Md ' );
var idBlnM = charIDToTypeID( 'BlnM' );
var idNrml = charIDToTypeID( 'Nrml' );
desc11.putEnumerated( idMd, idBlnM, idNrml );
var idClr = charIDToTypeID( 'Clr ' );
var desc12 = new ActionDescriptor();
var idRd = charIDToTypeID( 'Rd ' );
desc12.putDouble( idRd, c.rgb.red ); // RED
var idGrn = charIDToTypeID( 'Grn ' );
desc12.putDouble( idGrn, c.rgb.green ); // GREEN
var idBl = charIDToTypeID( 'Bl ' );
desc12.putDouble( idBl, c.rgb.blue ); // BLUE
var idRGBC = charIDToTypeID( 'RGBC' );
desc11.putObject( idClr, idRGBC, desc12 );
var idOpct = charIDToTypeID( 'Opct' );
var idPrc = charIDToTypeID( '#Prc' );
desc11.putUnitDouble( idOpct, idPrc, 100.000000 );
var idSoFi = charIDToTypeID( 'SoFi' );
desc10.putObject( idSoFi, idSoFi, desc11 );
var idLefx = charIDToTypeID( 'Lefx' );
desc9.putObject( idT, idLefx, desc10 );
executeAction( idsetd, desc9, DialogModes.NO );
// =======================================================
// =======================================================
executeAction( charIDToTypeID( 'CpFX' ), undefined, DialogModes.NO );
}" show debugger on runtime error
end tell
end try
end tell