Error creating rendition for a group


Using this function

async function exportRendition(myParentFolder, selection) {
    let scenegraph = require("scenegraph");
    const application = require("application");
    const rectangles = scenegraph.root.children.filter(node => node instanceof scenegraph.Rectangle);
    const groups = scenegraph.root.children.filter(node => node instanceof scenegraph.Group);
    if (rectangles.length > 0) {
        var children = rectangles;
        if (groups.length > 0)
            children = rectangles.concat(groups);


    try {
        const arr = item => {
            if (item instanceof Rectangle) {
                //selection.items = [item];
                const file = await myParentFolder.createFile(`${}.png`);
                let obj = {};
                obj.node = item //selection.items[0]
                obj.outputFile = file;
                obj.type = "png";
                obj.scale = 1;
                return obj
        const renditions = await Promise.all(arr);
        await application.createRenditions(renditions);
    } catch (err) {

gives me the error :
[Error: Expected ‘node’ field with a SceneNode value]

This error is happening when it tries to export the first Group item!

Can anyone help?

1 Like

I’ve allowed myself to give your code some formatting so it’s easier for us to read, understand and help :wink:. I hope you don’t mind…

For future reference: Posts gets formatted as Markdown, so that you can format a block of code like this:


resulting in something like this:

// my code

This makes the code easily readable and everyone much more willing to help :slightly_smiling_face:

Thanks! :slight_smile:

1 Like

Could you do a console.log(JSON.stringify(renditions)) before the await application.createRenditions(renditions) and post the output here?

Thank you very much in advance :+1:

Hello @pklaschka

Thank’s for your help!

The result is this:

1 Like

The nulls are from the following objetcs:

  Group ('NavigateInto') {
    width: 54.08, height: 54.08
    global X,Y: 278, -148
    parent: RootNode
    children: [Ellipse, BooleanGroup]
  Group ('DropDown') {
    width: 54.08, height: 54.08
    global X,Y: 358.95, -146.08
    parent: RootNode
    children: [Ellipse, BooleanGroup]
  Group ('EditButton') {
    width: 54.08, height: 54.08
    global X,Y: 431.75, -146.08
    parent: RootNode
    children: [Ellipse, BooleanGroup]
  Group ('Syslog') {
    width: 305.38, height: 122.15
    global X,Y: 298, -337
    parent: RootNode
    children: [Group]
  } ]

That most certainly is interesting. I’ll have a closer look (including testing the code myself) when I get home. Without testing, I (after 20 minutes of “manually processing” the code, i.e., simulating the APIs or my knowledge thereof with my brain :rofl: ) don’t see anything wrong with it…

1 Like

Yeah! Thanks! U’r right, it is strange, humm…Well meanwhile is time to move on to export components!


1 Like

It’s was a bug in the code lol…sorry!

Putting null entries in your renditions array will give this error message – every renditions request must be a valid rendition options object. In your example you can fix this by doing something like:

renditions = renditions.filter(item => item); // remove null entries

Also, please note that won’t always be a string that is a valid filename, so you’ll probably want to do some filtering there or else your plugin will fail sometimes. For example, designers can put * or / in layer names in XD.

Thank you for the feedback @peterflynn!

1 Like

Hi @Alberto, I am getting a similar null JSON. Can you please specify how did you resolve this?