Hello there, it’s been a while I got stuck with the following problem and need help: I want to create renditions of few selected artboards, and the order of the returned renditions is quite important for this case.
I know we shouldn’t rely on selection.items
order, but I’d like the renditions to be returned in the same order as in the selection. Now they are being returned in random order, which I can assume is something with not waiting the promise to be resolved while creating each file.
Here is the function from the following sample: https://github.com/AdobeXD/plugin-samples/tree/master/ui-panel-show-renditions
async function createRenditions() {
const folder = await fs.localFileSystem.getTemporaryFolder();
const arr = await selection.items.map(async item => {
const file = await folder.createFile(`${item.guid}.png`, { overwrite: true });
let obj = {};
obj.node = item;
obj.outputFile = file;
obj.type = "png";
obj.scale = 2;
return obj
})
const renditions = await Promise.all(arr);
const renditionResults = await application.createRenditions(renditions);
const renditionsFiles = renditionResults.map(a => a.outputFile);
return renditionsFiles;
}