Checking a selected is an artboard or not

I’m developing a plugin that needs to detect whether the selected object/element is an artboard or not. I have tried various method to verify this, but none of them seems working. .isArtbaord, .parent == Artboard etc. I haven’t seen much information about artboard in the doc. Also I wanted to generate an artboard next to last artboard (not selected)

1 Like

Try

const { selection, Artboard } = require("scenegraph");

if ( selection.items[0] instanceof Artboard){
    // your code here
}

Thanks @stevekwak that worked. Can you give me the link for plugin doc section where explaining instance of etc?. What about generating artboard to an empty space without overlapping other existing artboards?

if you search for instanceof on our site, it will give you many examples: https://adobexdplatform.com/plugin-docs/reference/how-to-read.html?q=instanceof
Also scenegraph module lists out classes you can access. Finally, you can get the positions of the existing artboards by traversing down from the rootnode (https://adobexdplatform.com/plugin-docs/reference/scenegraph.html#RootNode), finding the artboards, and getting their locations.

1 Like