TextObjectPoint Gap (Python)

Hi all,

I have been using TextObjectPoint to get a coordinate of a textbox. The problem is on some cases that point is not exact enough for my needs because there is a 0.05 inch gap between the point returned and the actual text (we have very slender pieces that the text needs to reside in, and it has been making it challenging to determine if the text point resides inside a closed curve - specifically, because I use PointInPlanarClosedCurve).

I have attached an image to hopefully better illustrate what I am talking about. Does anyone know how to get point ‘2’ in the image or maybe a center point? I could not find it stored in the object.

These textboxes are rotated at times, so if I have to calculate the point myself then I realize I could use the length and height of the textbox and appropriately stagger TextObjectPoint’s returned value, but I was curious if there was a better/cleaner way.

The text character is offset from the insert point of the text by the padding amount specified in the glyph definition for the font. Most of the time that is some positive distance.
You may get better results using the coordinates of the bounding box. If the text is rotated, the bounding box will not be aligned with the text.
There is a script that I’ll attach here that gets a rectangle around text. You may be able to adapt it to your process. I haven’t found who wrote it even though it has some RMA boiler plate at the top.
The second point you asked about is a Grip, index 1.
You can get it’s location like this (from @pascal):

obj = go.Object(0).Object()
    id = obj.Id
    pt2 = rs.ObjectGripLocations(id)[1]
    rs.EnableObjectGrips(id, False)

TextBox.py (3.0 KB)

1 Like

Thank you very much. This is exactly the information that I was looking for.