Extracting the coordinates and values of the text from an image in Legend

I know this question may be quite simple, but I have searched through ladybug_rhino.text module — ladybug-rhino documentation and it seems there is no corresponding function to extract useful information from <class ‘ladybug_rhino.text.TextGoo’>. It’s possible that my Python skills are not sufficient. :smiley:

Therefore, I may need your help, as this is one part of my image automation output project.

Wishing you all a smooth life.
Zhengrong

Hi @ZhengrongTao it is hard to guess what you are trying to do without a screenshot, but if you just want to get the text value and location from the TextGoo object, here is what you can try:

text_value = text_goo.Text
plane = text_goo.TextPlane
location = plane.Origin

Haven’t tested the above code, but hope you get the idea. Meanwhile, here is the source code: ladybug_rhino.text — ladybug-rhino documentation

1 Like

Thank you, you are right! @MingboPeng
I tested the code you provided me, and unfortunately, it didn’t work. However, that didn’t stop me from broadening my perspective. In the end, I managed to complete this example, and in my testing, it perfectly met my requirements.

import Rhino.Geometry as rg

# Input parameters
text_goo = Legend_Text

try:
    # Try to extract plane and text
    plane = text_goo.m_value.TextPlane
    text = text_goo.m_value.Text

    # Output parameters
    plane_output = plane
    text_output = text
except AttributeError:
    # If AttributeError exception is raised (no m_value attribute), set output parameters to None
    plane_output = None
    text_output = None

2 Likes

Hi @ZhengrongTao and @MingboPeng ,
Thank you for this example.
I tried to to get the horizontal and vertical alignments as well using the documentation here: ladybug_rhino.text module — ladybug-rhino documentation
But till now nothing is working although the information should be there somehow.
How can I retrieve this info?

hi @Erikbeeren ,
To be honest, I had the same doubts as you before. The LBT SDK didn’t offer me much in terms of solutions. In the end, I chose to refer to the Rhino Python SDK, which resulted in very effective outcomes .