Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

September 12, 2012

text animation using frame change

Using the very basic concept of the frame_change event, it is possible to update the body of a text object and render it as an animation.
import bpy
from random import choice
from string import ascii_lowercase as lowercase
if not 'Text' in bpy.data.objects:
bpy.ops.object.text_add()
def make_char_list():
text = "This is the Text and some hullabaloo"
char_list = []
for idx in range(len(text)):
random_text = ""
for token in range(idx):
if text[token].isspace():
token = text[token]
else:
token = choice(lowercase)
random_text += token
char_list.append(random_text)
char_list.append(text)
return char_list
char_list = make_char_list()
def my_handler(scene):
frame = scene.frame_current
if frame > len(char_list):
current_string = char_list[-1]
current_string = char_list[frame]
bpy.data.objects['Text'].data.body = current_string
bpy.app.handlers.frame_change_pre.append(my_handler)
view raw ft.py hosted with ❤ by GitHub


Search the blender API docs for more information on frame_change_pre