Change text on text billboard - Python

How can I change the text of a newly created billboard item such as:
text_b = scene.create_text_billboard(Vector3(1,1,1)) for example.

The code above creates a billboard with text “New Text” and I want to change it.

If there isn’t a direct way, since "The TextBillboard is a combination of a parent Cuboid with child TextItem ", how can I get the child? Because we can get all of the children with .children which returns a collection with BaseItems, but then, can I cast it to TextItem and would it work? I feel like this method would be way too much and unnecessary work but I am out of ideas.

Please, give me suggestions!

Hi @ami566, all Items inherit methods and properties from the BaseItem class, and all BaseItems have children as a property (ItemCollection), so you can simply reference the text property of the first child of the newly-created text object:

text_b = scene.create_text_billboard(Vector3(0,-1,1))
text_b.children[0].text = "Hello world"

Hope that helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap

3 Likes

Hi, @techleapnz , thank you very much! This does solve my problem!

1 Like