Copy link to clipboard
Copied
var docRef = app.activeDocument;
app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
var ab = docRef.artboards[0];
if ((((ab.artboardRect[2] - ab.artboardRect[0]) / 72) == 17) && (((ab.artboardRect[1] - ab.artboardRect[3]) / 72) == 20)) {
// do nothing
}
else {
docRef.artboards.add( [575,1601.78,1799,161.78] );
docRef.artboards.remove(0);
var abIdx = docRef.artboards.getActiveArtboardIndex();
var actAbBds = docRef.artboards[abIdx].artboardRect;
}
I want to say it works about 90% of the time. I have no idea why it doesn't always work, sometimes it will build the other artboard even though it is the correct size and I have no idea why. It is very frustrating haha. If anyone has an idea why it won't always work, please let me know. Thanks in advance!
Hi djbgraphicdesign,
perhaps this could be a rounding problem.
Please try something like this instead
if ((Math.round((ab.artboardRect[2] - ab.artboardRect[0]) / 72) == 17) && (Math.round((ab.artboardRect[1] - ab.artboardRect[3]) / 72) == 20)) {
Copy link to clipboard
Copied
Hi djbgraphicdesign,
perhaps this could be a rounding problem.
Please try something like this instead
if ((Math.round((ab.artboardRect[2] - ab.artboardRect[0]) / 72) == 17) && (Math.round((ab.artboardRect[1] - ab.artboardRect[3]) / 72) == 20)) {
Copy link to clipboard
Copied
I tried it and tested it about 50 times, it worked every time. Thanks for coming to my rescue again pixxxel!
Copy link to clipboard
Copied
I can see here the artboards.add method used with an array as argument but for me it always (more than 50times:) ) stops executing with
Error 1200: an Illustrator error occurred: 1346458189 ('PARM') error
in Illustrator CS5.1
Copy link to clipboard
Copied
Darn, I have illustrator 6 and I have never had that problem. I would ask that question again as a new discussion so more people could see it, I'm sure someone out there has the answer. I wish I could help but I have no idea
Copy link to clipboard
Copied
And it looks like you already did and pixxxel answered it haha. I should of checked the discussion board.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now