How to add numbers to Adobe Illustrator anchor points?


You know the "connect the dots" books for children where you connect the dots from 1 to 100 and a picture becomes visible?

I would love to do the same in Adobe Illustrator.

Is there a way (with any kind of scripting maybe) to add numbers to anchor points?

Is there a way (with any kind of scripting maybe) to color the points based on their anchor index (for example points 1-99 are black, 100-199 are blue etc.)?

8/11/2015 5:14:00 PM

Accepted Answer

To get started, easy dotted line creation and ordering can be accomplished using this script as explained by joojaa here.

The importance of arrangement is because the Document.selection array respects the order that the objects are stacked. You can take advantage of that to create a new text object for each object currently selected.

Here's a very simple snippet of JavaScript to point you in the right direction:

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

In action:

Illustrator script demonstration

I'm using shapes instead of anchor points for demonstration purposes but it does not matter if you use just anchor points instead. It would not be difficult to color the points based on their index. You should consult the Illustrator Scripting Reference for all the information required on how to custom tailor a script to suit your needs.

4/13/2017 12:46:00 PM