I’m coding in batchPlay, and here’s the basic format goes:
var batchPlay = require("photoshop").action.batchPlay;
var result = await batchPlay([
//Here lies the actions code(in actual object type), if more than one action: plus an ","
],{"synchronousExecution": false,"modalBehavior": "fail"});
So if I do a Select Layer Action it will be coded as :
{"_obj":"select","_target":[{"_name":"Layer 2","_ref":"layer"}],"layerID":[4],"makeVisible":false}
which contains absolute layer.name and layer._id, and I want to make this substituted with app.activeDocument.activeLayers. So the final code should be like this:
var batchPlay = require("photoshop").action.batchPlay;
var SelectedLayers = [ //Assume this is the array of app.activeDocument.activeLayers
{"_obj":"select","_target":[{"_name":"Layer 2","_ref":"layer"}],"layerID":[4],"makeVisible":false},
{"_obj":"select","_target":[{"_name":"Layer 3","_ref":"layer"}],"layerID":[5],"makeVisible":false},
{"_obj":"select","_target":[{"_name":"Layer 4","_ref":"layer"}],"layerID":[6],"makeVisible":false}
]
var result = await batchPlay([
SelectedLayers[0],
SelectedLayers[1],
SelectedLayers[2]
],{"synchronousExecution": false,"modalBehavior": "fail"});
This works well but I just can’t find the way to nicely output the array elements in this format, and in actual object type (debugger told me it not gonna happen with string type)
SelectedLayers[0],
SelectedLayers[1],
SelectedLayers[2]
I guess this question is more like a javaScript one even with Adobe stuffs.