This is where im up to, any ideas how to make it work?...
I've never used lists before so not sure if im describing the list correctly...
Also not sure if "to" is correct for putObject
function s2t(s) {return stringIDToTypeID(s)}
var r1 = new ActionReference();
var d1 = new ActionDescriptor();
var d2 = new ActionDescriptor();
var l1 = new ActionList()
//l1.putList(s2t("colorSamplerList"), 0)
r1.putProperty(s2t("property"),s2t("colorSamplerList"));
r1.putEnumerated(s2t("document"),s2t ("ordinal"), s2t ("targetEnum"));
d1.putReference( s2t( "target" ), r1 )
l1.putInteger( 0 )
d2.putList(s2t("colorSampler"), l1);
d2.putEnumerated(s2t("colorSpace"),s2t("colorSpace"), s2t("labColor"))
d1.putObject(s2t("to"), s2t("colorSampler"),d2);
executeAction( s2t("set"), d1, DialogModes.NO );
//FAILS
This is an example of Structure in JSON
{"_obj":"object","colorSamplerList":[
{"_obj":"colorSampler",
"color":{"_obj":"labColor","a":0.0,"b":0.01,"luminance":99.73},
"colorSpace":{"_enum":"colorSpace","_value":"labColor"},
"position":{"_obj":"paint","horizontal":{"_unit":"pixelsUnit","_value":100.0},"vertical":{"_unit":"pixelsUnit","_value":200.0}}},
{"_obj":"colorSampler",
"color{"_obj":"RGBColor","blue":254.99221789883269,"grain":255.0,"red":255.0},
"colorSpace":{"_enum":"colorSpace","_value":"RGBColor"},
"position":{"_obj":"paint","horizontal":{"_unit":"pixelsUnit","_value":138.5},"vertical":{"_unit":"pixelsUnit","_value":111.5}}}]}
No, it won't work like that. Moreover, you did not write it correctly.
Almost all lists are read-only properties.
Such as for example histogram, compsList, printerList, targetLayers, etc.
They cannot be changed with the "set" command.
Logically it should be like this
var class_name = "colorSampler";
var d = new ActionDescriptor();
var r = new ActionReference()
r.putIndex(stringIDToTypeID(class_name), 1);
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
//d1.put... some properties
d.putObject(stringIDToTypeID("to"), stringIDToTypeID(class_name), d1);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
but doesn't work.
Although if you change "colorSampler" to "compsClass" everything works fine. This is a flaw in Photoshop. There are a lot of them.