Rhino.Geometry.TextEntity bounding box problem

my Python script builds a TextEntity object and then tries to get its bounding box:

pla = Rhino.Geometry.Plane.WorldXY
pla.Origin = Rhino.Geometry.Point3d( 50, 50, 0 )
tex = '12345678’
hei = 10
jus = Rhino.Geometry.TextJustification.None
ftable = Rhino.RhinoDoc.ActiveDoc.Fonts
findex = ftable.FindOrCreate( ‘Arial’, False, False )
texent = Rhino.Geometry.TextEntity()
texent.Justification = jus
texent.FontIndex = findex
texent.Plane = pla
texent.TextHeight = hei
texent.Text = tex

box = texent.GetBoundingBox( False )

but the bounding box has zero height and width
I have to add the text to the Rhino document and get back its TextEntity object to get a working bounding box
Is this expected behaviour ?
Or am I making mistakes in building the object ?

Yes it is. An object’s bounding box is not calculated until it is added to the document.

OK, thanks Dale.

This does seem like a pretty lame bug though. Dale, could you add this to my list of RhinoCommon bugs to fix? Thanks.

I’m currently running into this problem (Rhino 5 SR7). What is the current status of this issue?

I don’t see any change when trying Emilio’s script, so looks like it hasn’t been fixed yet. @stevebaer I also didn’t find any bugtrack item for it, but maybe I missed something.


Looks like it hasn’t been implemented yet. Sorry guys

How do you search for that item in youtrack? Must be something basic I’m missing here… --Mitch

Same here…

I searched for

Geez, I searched for a bunch of stuff including subsets of those - don’t know why it didn’t come up.

I also faced the exact same problem…
The trick I used to go around it is to explode the textentity, get all control points and construct a box from that, with the plane you used to create your textentity…

Not sure the BB of the control points will give you the correct BB of the objects themselves - better to get the BB of the exploded curves directly… no? --Mitch

I was of course digging into this first with GeometryBase.GetBoundingBox() but I got stuck because I thought there is no way you can have an array/list as a GeometryBase. Any hint on this?
It is also not clear in the SDK how to construct a GeometryBase from scratch.

If you want to get the combined bounding box of multiple objects you need to use the Union(BoundingBox, BoundingBox) method, you march through the list and union each succeeding item with the result of the union of the preceding items. Have a look at how the rhinoscriptsyntax rs.BoundingBox() method is written…


Ah yeah, makes sense. cheers