Skip to main content
Known Participant
July 1, 2009
Question

Bounds around a text art

  • July 1, 2009
  • 1 reply
  • 1489 views

I am trying to get the bounding box around selected text art objects so I can draw a box around them.  I am using

GetPreciseArtTransformBounds which returns an ArtworkBounds but it returns 4 values of Left, Top, Right, and Bottom.  Is this the correct approach or should I be using another function.  If this is correct how do I intepret this for the X,Y values of all 4 corners which would encapsulate the text art?

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
July 2, 2009

GetPreciseArtBounds is probably not the function to use. I talked with some Adobe engineers a few years ago and they told me they added that to solve a particular problem they had in a very specific instance -- you should be getting by with just GetArtBounds or GetTransformArtBounds. Those will give you much more straight-forward AIRects

tony_bellAuthor
Known Participant
July 6, 2009

GetArtBounds and GetArtTransformBounds seems to give me the same results.  If the text is not rotated (ie, place at 0 degrees) the

AIRealRect artwork bounds would be correct but if the text is rotated (say 35 degrees), these coordinates would only give me the minimum bounding rectangle.  What I need is the actual XY corrdinate locations for all for corners of the text.  If you select a text artwork then rotate it, you will see the outline box of the text as you rotate it.  This is what I need.

A. Patterson
Inspiring
July 6, 2009

Honestly? I don't know. This is something that has stumped me forever. I'm guessing there's a way -- since they use the same SDK we do for about 98% of Illustrator -- but I'm not sure.

If its point text, one thing you *might* be able to do is try something like this:

1) Get the angle of the text (get its matrix, as for the angle)

2) Use GetArtTransformBounds() using the angle negafied

3) Now rotate the bounds back using the angle

I don't think if this will work, but it might. Still, it'd be nice if there was a goddamn way to get those pretty, actually useful bounds we see Illustrator displaying all the time. As to how, your guess is as good as mine.

[Edit: 'godd amned' is censored?]