Control Text

I’d like to use a script that copies an attribute (LocZ) from one object to a Font object’s text display. Could someone explain the process of accessing this text property? I looked under the Blender module, and it has something called Text, which has something called Get. Is this it? Thank you very much!

Blender.Text.Get(‘name’) will get you a text block - for example, a script. I think you want Blender.Text3d.Get(‘name’).

Thanks. But in what format should the modifier be? I tried a string like “OBtext_01” and “text_01”. Both were stated to be not found in the console window. Thanks again.

Hmm. I just tried creating a default Font object called “Font”. I could access it as Blender.Object.Get(“Font”). Text3d seems to have a nested object from the Font object (which was called “Text” by default). You can always list the names of objects available by calling Get without any arguments, e.g. Blender.Text3d.Get()

Thanks! :smiley:

import Blender
ob = Blender.Text3d.Get()[0]

Isn’t the Redraw() function supposed to update everything? The effects don’t take place until the next time I open the file, and I want this to work realtime in an animation.

What you may want to look into is the script link for an object. What this does, is allow you to attach a specific script to an object so that when an event occurs (like frame change or render), the script will run and the object can alter itself.

Here is an example.

Reset Blender, delete the default cube.
Create a Font object.
Create a text window and paste this code into a new text document.

import Blender
from Blender import *
# Are we running as a script link?
if Blender.bylink: 
    if Blender.event == "FrameChanged":
        ob = # This fetches the object this script is attached to.
        myText = ob.getData()
        ob.makeDisplayList() # Reflect the changes to the text object to the scene.
    print ("Script Link event: %s for %s" % (Blender.event,

Click the Script button in the buttons window. (right next to the pac-man icon).
Click Enable Script Links button.
Now choose the Object (denoted by the axis icon), not the world icon (that is for scene scripts).
Click the New button for objects, not scenes.
Now choose the name of the text document from the list that pops up.
I think it defaults to frameChanged, but you may have to specify that event.
At this time, you can Press ALT-A and the current frame number will be displayed in your font object.

Feel free to modify the script to display the data you require.

Thanks! I never knew exactly why the Script Links window was done away with.