Rhino.Geometry.TextEntity bounding box problem


#1

Hi
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 ?


(Dale Fugier) #2

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


#3

OK, thanks Dale.


(Steve Baer) #4

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


#5

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


#6

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.


(Steve Baer) #7

http://mcneel.myjetbrains.com/youtrack/issue/RH-22566

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


#8

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


(Wim Dekeyser) #9

Same here…


(Steve Baer) #10

I searched for
"rhino-geometry-textentity-bounding-box"


#11

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


(Paul Poinet) #13

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…


#14

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


(Paul Poinet) #15

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.


#16

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…

–Mitch


(Paul Poinet) #17

Ah yeah, makes sense. cheers