I want to simulate a multi-agent system with Blender. It's almost done, but I experience a problem.

System agents speak to each other by passing messages, and I want to pass messages between them. I considered a text object as container of these messages. There is no constraint on the number of agents.

I want to create one (or some) text object and reuse it many times, by only changing source and destination locations and body texts.

After some search, I realized, that there is no data_path that supports keyframe_insert() to change the body text. Beside that I found dynamic text, but my context is extremely different with that method's context.

I want to change text on every keyframe, and it depends on my simulation's input.


1 Answer 1


An application handler could be used to read subtitle data from your simulation module and display it by editing a text object.

import bpy
from bpy.app.handlers import persistent

def frame_change(arg):
    print("Load Handler:", bpy.data.filepath)
    t = bpy.data.objects["Text"]
    # here get the text you want to display
    label = ("Frame # %d" % bpy.context.scene.frame_current)
    t.data.body = label

  • $\begingroup$ Thanks stacker for your attention. However it could be a solution; but It is not efficient at all. because i have so many message and this function should fill these message in all frames. but i need to change message only in key frames. $\endgroup$ Sep 12, 2014 at 7:25
  • $\begingroup$ please guide me if I am in wrong way $\endgroup$ Sep 12, 2014 at 7:33
  • $\begingroup$ When you don't need to change the text content in frames just skip the code until you reach a 'keyframe'. Compared to the costs of rendering I wouldn't worry on efficiency. $\endgroup$
    – stacker
    Sep 12, 2014 at 8:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .