Newbie question: Script for displaying a textfile as animation?

Hi,

is it possible to write a script in Blender Python which opens a text file and creates an animation which displays the text file e.g. character by character like an old computer display? How would one go about this? Is there any sample scripts anywhere?
I have to admit that I don’t speak any Python. Only a bit C/C++, PERL, bash and so on…

-S

The problem is that the animation system doesn’t support Text, so you may have to resort to quite a bit of trickery.

One way would be to create text objects for every intermediate state, liek “H”, “He”, “Hel”, “Hell”, “Hello”, automatically with the same material, but turn their visibility on and of on different frames, using F-Curves.

So it is possible to write such a script, but you have to dig into the API documentation. Especially take a look at how to modify F-Curves and Text objects!

Thanks for the pointer! That’s a bit of a bummer that the animation system doesn’t support text… If the text is longer, that would result in a massive amount of objects…

you can use handlers to write the text object data body
or try the animation nodes addon to make it with nodes


import bpy
with open('C:\\Temp\\info.txt') as t: info = t.read()
obj = bpy.context.scene.objects['Text']

def change_txt(scene):
    f = bpy.context.scene.frame_current
    try: obj.data.body = info[0:f]
    except: pass

pre = bpy.app.handlers.scene_update_pre
pre.clear()
pre.append(change_txt)

edit:re-read your post, you want the text to write letter by letter, there’s an addon around to do that
just modified the script above anyway

Cool! Thanks! The script definitely is a good starting point for me!