I’m currently working on a plugin that duplicates a layer group to a new document and saves as a PNG using the SuperPNG plugin. I’ve gotten lots of the foundations for my plugin up and running, and most things work, except for actually saving the files.
I’ve spent a significant amount of time searching for answers, and I am unable to get a document to save using a BatchPlay action. I’ve even tried simple operations such as resizing, with code copied from Alchemist, but with no success. I’ve searched through the UXP documentation, but it can be a bit confusing and doesn’t always have complete samples it seems.
Are there any comprehensive samples out there that show how to achieve something like this in API 2? I’ve directly copied several different samples from this forum, and I can’t seem to get the action to execute.
Any guidance would be appreciated! I’m a bit new to JavaScript, so I’m sure my problem stems from that.
I didn’t include any code as I didn’t want to just post other people’s code (I’ve just been trying code snippets directly from the forums to see if I can get anything to work), however here are the two topics I have referenced and directly tried:
I’ve taken the code as is and modified it with any additions in the replies that supposedly make it work. The code was put in an async function being called on the click event of a button.
From my understanding after doing more research, ExecuteAsModal is required in API 2, though I’ve found the documentation on this a bit hard to follow.
As a place to start though, here’s a sample I’ve put together that doesn’t work based on output from Alchemist: