0

There is getActiveArtboardIndex and setActiveArtboardIndex, I can get the Artboard object with getByName.

But how do I set active artboard by name?

Or at least get index from the Artboard object?

1

Not the most elegant way, but still solves the problem:

var docRef = app.activeDocument;
var ABName = "Artboard Name";
function setActiveArtboardBy(name) {
    var artboard = docRef.artboards.getByName(name);
    for (i = 0; i < docRef.artboards.length; i++) {
        if (docRef.artboards[i] == artboard) {
            docRef.artboards.setActiveArtboardIndex(i);
            break;
        }
    }
}
setActiveArtboardBy(ABName);
  • 3
    Please explaine what this piece of code does. Only presenting the code kicks off all reader not able to unstand what you did ... – Mensch Oct 2 '14 at 16:54
  • Kurt, it takes artboard object by given name, then goes through all artboard comparing with it. When it figures out the right one it sets it as active and breaks the cycle. That is what this function does. – amrok Oct 2 '14 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.