Displaying text with location based on points using Python Scripted Components

rhinocommon
textentity
python
scripting

#1

Hi everyone,

I’d like to display text (as in floating text, not text dots) whose ‘anchor’/location is based on a point, similar to the .gh file given by David Rutten in this post:How to display text. I’m attaching the same file here that David posted in that discussion in case anyone misses it. drawing3dalignedtext.gh (6.8 KB)

However, I’d like to do it in Python. From what I’ve observed (intermediate Python coder, so I’m familiar with coding in Python, but not that great) there isn’t an equivalent of the C# override for DrawViewportMeshes (correct me if I’m wrong!). How would I go about implementing the same thing in Python, completely as a script inside a component (no outside components needed except for input)?

Example:
text_dispaly

Other things I’d like to do: the text should adjust for perspective, and the font and size can be changed. I don’t need to bake the text or anything, but I may need to keep track of the text content and store it inside the User Data of the point should I bake it, because I am using the outputs of certain operations
as inputs for others.

Much thanks in advance!

P.S. I’ve received suggestions on using Custom Display, but I’d like to avoid using it as it tends to crash my Rhino app.


(Giulio Piacentino) #2

Rhino WIP has (and Rhino 6 will have) a GhPython component mode that allows to override most methods of GH_Component, including DrawViewportMeshes.

A similar, but slightly simpler example is posted on this discussion, where DrawViewportWires is overridden (§ 5):

Please let me know if this is helpful,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#5

Thanks @piac for the information. Unfortunately, I’m building my component using Rhino 5 (due to it being more accessible to students) but I’ll give this a whirl in the Rhino WIP. It is particularly helpful should it be carried through to the official Rhino 6 release, as based on my own experience I’ve needed to do particular operations with Display that are not available using CustomDisplay (like this post).


(Giulio Piacentino) #6

OK, great, please let me know.

It is planned for this to be part of the Rhino 6 release.

Please let me know if you need more help!


(Giulio Piacentino) #7

A post was split to a new topic: Storing data in pure geometry classes