How to create Rectangle object required by add method of the artboards object in Illustrator CS5.1+?
adobe-illustrator, javascript
Solution
After searching extensively I've found this workaround:
var newRect = function(x, y, width, height) {
var l = 0;
var t = 1;
var r = 2;
var b = 3;
var rect = [];
rect[l] = x;
rect[t] = -y;
rect[r] = width + x;
rect[b] = -(height - rect[t]);
return rect;
};
artboard = artboards.add(artboards[0].artboardRect);
artboard.name = "new name";
artboard.artboardRect = newRect(0, 0, 200, 50);
Problem
I'm trying to add new artboard with the help of java script. I wasn't able to find solution nowhere. The scripting guidelines from adobe are just poor (to not use more strong words). What ever I'm trying it returns the error: Error 1242: Illegal argument - argument 1 - Rectangle value expected when I use value of `artboard.artboardRect` from other artboard then it creates artboard in the same place but I can't modify it (resize) which makes this option useless. ``` artboards.add(artboards[0].artboardRect);//works artboards.add([0,0,200,50]);//Error 1200: an Illustrator error coccurred: 1346458189('PARAM') var rect = artboards[0].artboardRect; rect[0] = 0; rect[1] = 0; rect[2] = 200; rect[3] = 50; artboards.add(rect);//Error 1242: Illegal argument - argument 1 - Rectangle value expected ```