Skip to main content
Inspiring
June 27, 2023
Answered

Artboard name to Content

  • June 27, 2023
  • 1 reply
  • 440 views
I work with the script and it works very well. But I can only use one Active Artboard at a time. Can someone help me so that all artboard names are automatically written into the content

1000 Thanks


#target illustrator
function test(){
    if (app.documents.length == 0) {
        return;
    }
    var doc = app.activeDocument;
    var newText = doc.activeLayer.textFrames.add();
    var idx = doc.artboards.getActiveArtboardIndex();
    var currentArtboard = doc.artboards[idx];
    newText.contents = currentArtboard.name;
    newText.top = currentArtboard.artboardRect[1] + 10;
    newText.left = currentArtboard.artboardRect[0] + 10;
    newText.textRange.characterAttributes.size = 20;
};
test();

 

 

 

This topic has been closed for replies.
Correct answer Charu Rajput

Hi,

Try following version

#target illustrator
function test() {
    if (app.documents.length == 0) {
        return;
    }
    var doc = app.activeDocument;
    for (var a = 0; a < doc.artboards.length; a++) {
        var newText = doc.activeLayer.textFrames.add();
        var currentArtboard = doc.artboards[a];
        newText.contents = currentArtboard.name;
        newText.top = currentArtboard.artboardRect[1] + 10;
        newText.left = currentArtboard.artboardRect[0] + 10;
        newText.textRange.characterAttributes.size = 20;
    }
};
test();

1 reply

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
June 27, 2023

Hi,

Try following version

#target illustrator
function test() {
    if (app.documents.length == 0) {
        return;
    }
    var doc = app.activeDocument;
    for (var a = 0; a < doc.artboards.length; a++) {
        var newText = doc.activeLayer.textFrames.add();
        var currentArtboard = doc.artboards[a];
        newText.contents = currentArtboard.name;
        newText.top = currentArtboard.artboardRect[1] + 10;
        newText.left = currentArtboard.artboardRect[0] + 10;
        newText.textRange.characterAttributes.size = 20;
    }
};
test();
Best regards
Inspiring
June 27, 2023

Wow, it works really really good Thank you. Happy Happy day