0

How do I change the size and rotation of the numbers in this script ?

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 - 10;         //Position the text object underneath
    text.left = selected[i].left;
}

This script adds a number to every selection (group or path) from this post. I'm looking for a way to change the size and other appearances of the number.

1

Well, you got the characterAttributes of a TextRange object, so you would do this for example, to change the font size:

text.textRange.characterAttributes.size = 16; // make it 16pt font size

Find more properties you can manipulate on page 17 of this javascript reference pdf available online! Your newfound powers will only stoke your huger for more Adobe Illustrator scripting adventures. Have fun!

1

While you could change the script let me point a (obvious) trick that does not rely on you understanding how to change the script. Once youve done running the script:

  1. Select all the newly created text objects (select → Object → all text objects)
  2. Use Window → Type → Character to change the font
  3. (opptional), use Object → Transform → Transform Each... to move them about.

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.