Moving an object by center point to an object.bounds.center
-
Hi
I'm wondering if it's possible to move a "entity.add_text" object that I have added to the scene, to the center of a group in the scene, so that the center of the add_text object is in the center of the group ?
Any hints are welcome. I can add the text object to the center of the group, but it is aligned to the top-left corner of the text object, not the center

Thanks
Jorgensen -
The groupg's bounding box (bounds) has max and min XYZs. Find those and use something to find the mid-way between them (= the center)...
Assuming that your group is named 'group'...
...
max=group.bounds.max; min=group.bounds.min
mid_point=Geom::Point3d.linear_combination(0.5,max,0.5,min)
...
Unfortunately plain text is left justified. However you could place some 3D-text centred - see my TextTag stuff for clues -
I guess the whole point is to understand whether there is a way to know 'in advance' the size of a text (based on string and font) so that it can be positioned accurately in the model at creation.
On my side I did not find a way to do that.
-
Hi TIG and Fredo
Thanks for your input.
I'm thinking about to try and use 3dtext instead. But until further I'll have a workaround where I modify the position by x,y, z axis. This is not perfect, because the texts don't have the same width.
Thanks
Jorgensen
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement