How to duplicate current working artboard and make changes over them?

If I am working with an artboard which contains rectangles, I need to duplicate the artboard with those rectangles and I must change the co-ordinates of the rectangle in the duplicated artboard only (just to animate).

How to do that in my plugin development?

Use commands.duplicate() to clone the Artboard node, then on each Rectangle use APIs from the SceneNode base class like moveInParentCoordinates(), placeInParentCoordinates() or the translation setter to change positions as desired.

You may also want to read the general docs about coordinate systems in XD since nested coordinate systems can be confusing if you’ve never worked with them before.


How to select my current artboard node. Is there any default name for my current artboard? since I’ve not declared any art board node name.

1 Like

selection.focusedArtboard is the best indication of the “current” artboard for most use cases.


I have tried it :
Here is my Function:

function parallaxFinal(){
          const { selection} = require("scenegraph");
          const {Rectangle} = require("scenegraph");
          let maskShape = new Rectangle();
            maskShape.width = 1920;
            maskShape.height = 1080;
        let commands = require("commands");

Is this correct way to do duplicate of my current node ? ( The last three lines of code! )
This doesnt seem to do what it need to! :slightly_frowning_face:

Commands always target the current selection. So you need selection.items = [selection.focusedArtboard] first.

1 Like

Thanks! That works!
So If i want to change the parentCoordinates of the rectangles in the duplicated artboard, first I must select the duplicated artboard. What should I do to select the duplicated artboard?

No need. Only the commands APIs require you to select the nodes you want to change (because they’re literally automating commands from XD’s UI). Other operations like changing node position don’t require you to make the node selected first.

But In order to make changes over the nodes in " Duplicated artboard " alone, I have to select the duplicated artboard right. If I select a node with the node name, for example - if my node is “fgRect”. If I select them using " selection.items=[fgRect] " and change their co-ordinates, will they affect the homeArtboard rectangle? Since both the artboard contains same rectangle name “fgRect”.