Skip to main content
Known Participant
November 20, 2013
Question

Text traversal in an artboard

  • November 20, 2013
  • 1 reply
  • 686 views

My plugin need to traverse text from a artboard, assign a number to each text (and show it next to the text) and list them in a separate (new) text frame on the same artboard.

1. Traversal for assigning numbers:

I am aware that while finding text frames from the artboard, they are traversed in the same sequence as they are stored in the Ai document.

I use sAIArtSet->MatchingArtSet() for finding the text.

This sequence do not match with the normal english book reading style : left to right and top to bottom.

Thus the numbering done according to my requirement is rather random.

Is there any way to traverse text according to the  left to right and top to bottom style ??

2. Displaying a new text frame on the artboard:

What is ideal for a non-image simplest text display on the artboard ?

What I can imagine is, create a text range and add it in a text frame(point text) art on  the artboard.

When I try to display texts, all appear in a single line. How do I write multiline text, I want something like '\n' ?

eg: The text should look like :

     a. abc

     b. xyz

     c. pqr

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
November 20, 2013

No, there is no way to traverse art based on canvas position. You'd have to visit all text frames and work that out for yourself. Feels doable though, just get a list of text frames & their bounds, then sort the list as you'd like (by x & y of top left maybe?).

DatasetAuthor
Known Participant
November 20, 2013

@Patterson: I suspected so.

Anyway, can you please help me with the 2nd part of the question. Displaying the text.

A. Patterson
Inspiring
November 20, 2013

Presumably you don't want to actually put text objects with numbers there? If not, I think your only option is to use an annotator. You're free to have as many annotators as you need in your plugin, so no reason you couldn't have a separate one to display a number next to each of those text frames in the order of your choosing.