Friday, June 22, 2012

Script to Extend the Artboard in Adobe Illustrator

It's pretty easy to change the size of the artboard (i.e., canvas) in Adobe Illustrator, but as I've said in some previous posts I've started to experiment with large format wireframes / navigation diagrams.  When you zoom way out (or print small) it looks like a navigation diagram, but you can zoom way in (or print poster size) to see the wireframe details.  I'll put up an example in a later post.

Anyway, I tend to start with the artboard at tabloid (17x11) or 2x tabloid (34x22) and then grow the artboard incrementally as I go.  I change the artboard regularly enough and in such a predictable way that I went ahead and made the script below:

----

if (documents.length == 0) {
    alert("Must have a document open!");
}


TABLOID_LANDSCAPE_W = new UnitValue (17, "in");
TABLOID_LANDSCAPE_H = new UnitValue (11, "in");


curWidth = activeDocument.artboards[0].artboardRect[2];
curHeight = activeDocument.artboards[0].artboardRect[3];


isWidth = confirm("Extend width?");

if(isWidth) {
    newWidth = curWidth + TABLOID_LANDSCAPE_W.as("px");
    activeDocument.artboards[0].artboardRect = [0,0,newWidth,curHeight];
} else {
    newHeight = curHeight -TABLOID_LANDSCAPE_H.as("px");
    activeDocument.artboards[0].artboardRect = [0,0,curWidth,newHeight];
}


----

It's pretty simple, but I thought I might as well share the idea and the script for whomever might find it useful.  Here's how it works:
  1. First check to make sure a document is open.
  2. Define the width and height that I'm going to use to extend the artboard.
  3. Get the current width and height of the artboard.
  4. I use a confirm dialog to ask if you want to extend the width, otherwise the script will extend the height.
  5. Finally, calculate the new width or height and extend the artboard.

No comments: