Hello,
I have this code
await core.executeAsModal(async () => {
const resDesc = await action.batchPlay([object], {
synchronousExecution: true
});
resolve(resDesc[0]);
});
But if meanwhile doing this, I do a getFileForOpening, the first code is cancelled. And if I do a saveAs, both are cancelled.
document.saveAs.psd(entry);
const file = await fs.getFileForOpening({ types: ['xml'] });
How can I solve this?
Thanks
I’m very confused about the first part of your script.
- You tell BP to run synchronously, but you also
await
. Why? synchronousExecution: true
already makes BP to return a normal result instead of a Promise
- What does
resolve(resDesc[0])
actually do? I assume this is your custom function. Name implies it should resolve a promise, but… read first bullet point
Sorry, I was mixing things
My code was redundant, I improve it but I had the same problem
export const batchPlay = async (object) => {
let response;
await core.executeAsModal(async () => {
response = await action.batchPlay([object], {});
});
return response[0];
};
I am doing several calls at the same time to batchPlay and sometimes returns empty value, but I fixed it with a semaphore
My second problem is that saveAs sometimes works, sometimes no, how I have to save a copy from activeDocument?
I see this but it doesn’t work for me: Saving a JPG to a selected folder - #5 by 4t0m1c
It returns
Event: saveDocumentSelection may modify the state of Photoshop. Such events are only allowed from inside a modal scope. See https://www.adobe.com/go/ps_executeasmodal for details.
What I have to do?
So did you check the link in the error? You already use it, but apparently not everywhere where it’s needed
Okey, solved, thanks
const document = app.activeDocument;
await core.executeAsModal(async () => {
await document.saveAs.psd(entry, {}, true);
});