Looking for a simpler way to add an anchored object to a cell

Hang in there, this is a weird one.

I’m creating a plugin that generates bus timetables. This includes generating a “timepoint” for each bus stop, which is a colorful symbol that helps the user find the bus stop on the map. Here’s my current example, the top row of colorful circles are the timepoints:

This is a simplified version of how each timepoint is created in my plugin:

  1. Create an oval in the document and style it
  2. Create a textframe with a letter, and convert to outlines
  3. Align and group the oval and letter
  4. Select and cut the newly-formed group
  5. Select the cell’s first insertion point and paste the group

And this works! It works well! But it’s slow and goofy. Here’s what it looks like:


You can see the timepoint created at the document origin and then pasted in each cell. Each timepoint is an anchored object and acts like a character:


Now the problem is this approach is pretty slow, and I figure there must be a more direct way to set the cell’s contents instead of cutting and pasting. Well how about I just set the cell.contents to the group, then?

This approach just sets the cell types to graphic cells. Converting them to text cells results in the intended behavior, but the stretched timepoint remains. I’ve also tried converting the cell to a text cell before setting the contents, but same thing.

So this all boils down to: how can I programmatically insert an anchored object into a text cell?


Thank you so much! Exactly what I was looking for.