Using both saveAs or Batchplay to save both a JPG or PNG works from a panel. Using the same code but from a dialog doesn’t seem to actually create the file for saving. Both use getpluginFolder().
Is there something needed to allow a dialog to save?
Example code:
const dataFolderToSaveFileTo = await fs.getPluginFolder();
//create the file with combined name and path
const holdNewFile = await dataFolderToSaveFileTo.createFile(`${passedFileName}.png`, { overwrite: true });
await core.executeAsModal(async () => {
try {
const activeDocument = require("photoshop").app.activeDocument;
await activeDocument.saveAs.png(holdNewFile, true);
}
Already wrapped in a try/catch - catch never fired, no errors in the console. After this save, I upload the file we’ve just created (temporary file so we can upload it).
Here is a primitive solution, As it is stated above photoshop allow only one modal state each time, I had this same issue, from dialogue I wanted to open the PS preferences, how I solved I added a
close()
Before running the code that will open PS preferences, you can add another Open dialogue at the end if you need to open the dialogue again. Primitive, but worked for me.
Same issue regardless of setting interactiveMode to true or false. File is never created to disk it seems. ‘holdNewFile’ does have the nativePath set correctly to where I’m trying to temporarily store it.
Thank you for this idea. This has allowed me to save the file. Issue now is that the dialog closes and until my task is finished server side, I don’t display the ‘upload successful’ message. I feel the user may wonder what’s going on.
For some reason, executeAsModal isn’t showing the progress bar I previously had. However, there seems to be issue somehow that it doesn’t always show up anyway (longer than 2 second task, so it should be).
Great, it worked for you. You can handle it how you see fit, for example when upland is done show an alert to let users know, or reopen your first dialogue again.
Gone with showing successful message and not showing it again. My use case doesn’t make sense to exporting it again immediately anyway. Thank you for your help.
A dialog is intended to ask a question. For example, Export As asks what (limited) alterations would you like before saving a copy. The file dialog that will appear asks what name (and path). Upon supplying those answers, the user clicks the “action” button, say Export or Save. The dialog closes, and then the action is taken.