How can you to add this Artboard

How can you to add this Artboard.

RootNode Children add Artboard.

In the way below, it does not work.
Am I making a mistake?

function myCommand(selection, documentRoot) {
    let art = new Artboard();
    art.width = 100;
    art.height = 100;
    documentRoot.addChild(art)  
}
2 Likes

Sorry, but is this meant as a question (it’s not quite clear since you used . and not ? which means this could also be meant as a tip on how to add artboards…)?

First of all, you have one obselete closing brace } in line 6 :wink:

Also, you can wrap code in ``` [new line] [your code] [new line] ```. I’ve taken the liberty of formatting it for you :wink:

1 Like

Thank ynu pklaschka.
updated issue.

1 Like

If you remove this and (optionally) add a semicolon after documentRoot.addChild(art), it should work.

1 Like

I fixed it but I could not do it.

1 Like

Sorry. I forgot that you’ll need to import Artboard from the scenegraph module. Add

const {Artboard} = require('scenegraph');

before the function (resulting in the code below) and it should work (i.e. it does work – I’ve just tested it) :wink:

const {Artboard} = require('scenegraph');

function myCommand(selection, documentRoot) {
   let art = new Artboard();
   art.width = 100;
   art.height = 100;
   documentRoot.addChild(art)  
}
3 Likes