Action manager set (shape) layer color
Hi,
Following some guides, I was able to mostly do the thing I want: recolor all shapes, one by one (because each shape can have different target color).
Looking at ScriptingListener, I found this part (I didn't try cleaning it yet, like removing the strokes, as I want it to work first):
var idsetd = charIDToTypeID( "setd" );
var desc1113 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref169 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref169.putEnumerated( idcontentLayer, idOrdn, idTrgt );
desc1113.putReference( idnull, ref169 );
var idT = charIDToTypeID( "T " );
var desc1114 = new ActionDescriptor();
var idFlCn = charIDToTypeID( "FlCn" );
var desc1115 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc1116 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc1116.putDouble( idRd, 90.038912 );
var idGrn = charIDToTypeID( "Grn " );
desc1116.putDouble( idGrn, 16.245135 );
var idBl = charIDToTypeID( "Bl " );
desc1116.putDouble( idBl, 28.404669 );
var idRGBC = charIDToTypeID( "RGBC" );
desc1115.putObject( idClr, idRGBC, desc1116 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc1114.putObject( idFlCn, idsolidColorLayer, desc1115 );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
var desc1117 = new ActionDescriptor();
var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
desc1117.putInteger( idstrokeStyleVersion, 2 );
var idfillEnabled = stringIDToTypeID( "fillEnabled" );
desc1117.putBoolean( idfillEnabled, true );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
desc1114.putObject( idstrokeStyle, idstrokeStyle, desc1117 );
var idshapeStyle = stringIDToTypeID( "shapeStyle" );
desc1113.putObject( idT, idshapeStyle, desc1114 );
executeAction( idsetd, desc1113, DialogModes.NO );
The first ActionReference (169 in this case) should be responsible for which layer gets this change applied to (selected in this case).
I've tried changing it to:
var ref = new ActionReference();
// ref=.putIdentifier(s2t('layer'), getLayerProperty(index, 'layerID'));
ref.putIndex(s2t('layer'), index);
desc1113.putReference( idnull, ref );
Trying both the index and identifier (separately and together), trying "contentLayer" as class, etc etc.
But I can't get it to apply this effect on the layer (by index or identifier, doesn't really matter, as I can get both). Any help please?
