0

So I have this script which numbers every objects in Illustrator:

var document = app.activeDocument;                   //Use the current open Ai File
var selected = document.selection;                   //Use the current selection in Ai

for (var i = 0; i < selected.length; i++) {         //Iterate over every selected object
    var text = document.textFrames.add();           //Add a new text object
    text.contents = i + 1;                          //Set the corresponding number text
    text.top = selected[i].top - (selected[i].height/2);                    //Position the text object underneath
    text.left = selected[i].left + (selected[i].width/2);
}

This writes a number over every object. How can I change the script so that the number and the object will form a new group? And is there a way to center the new text object both vertically and horizontally in the object?

(Edit: added centering)

Your Answer

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

Browse other questions tagged or ask your own question.