Using API 1, I was able to create a new channel on the Channels panel in Photoshop with the following code from Alchemist:
await require('photoshop').action.batchPlay([
// Create a new channel
{"_obj": "make","new": {"_obj": "channel","colorIndicates": {"_enum": "maskIndicator","_value": "maskedAreas"},"color": {"_obj": "RGBColor","red": 255,"grain": 0,"blue": 0},"opacity": 50}},
], { "synchronousExecution": false, "modalBehavior": "wait" })
With API 2 inside a targetFunction called with executeAsModal , I use the following code and nothing happens.
await require('photoshop').action.batchPlay([
// Create a new channel
{"_obj": "make","new": {"_obj": "channel","colorIndicates": {"_enum": "maskIndicator","_value": "maskedAreas"},"color": {"_obj": "RGBColor","red": 255,"grain": 0,"blue": 0},"opacity": 50}},
], {})
Is this a bug with API 2 or am I doing something wrong?
In API 2, the result in the debugger shows:
So it looks like the code executes just fine. I just doesn’t create a new channel on the Channels panel.
Of note, I also tried using the Alchemist-generated code for using calculations to create a new channel and get the same result. The code executes according to the debugger, but no new channel is created on the Channels panel.
I wonder if being in a modal state prevents new channels from being created and if so what the workaround is for creating them.