6

Is it possible to link text objects in such a manner, that changing the text content on one object will automatically also change the text of another text object.

To clarify, I do not want to link any other properties of those two objects (like fonts for example), only the source text.

Antti
  • 1,747
  • 4
  • 20
  • 37

3 Answers3

7

this a script that uses the scene update handler to synchronize two text object content :

  • select the two text objects only
  • copy and paste the script and click run
  • once you edit one of the text objects the other one will get updated accordingly

import bpy

obj1 = bpy.context.selected_objects[0].name
obj2 = bpy.context.selected_objects[1].name

def link_text_objects(scene):
    obj = bpy.context.active_object
    if obj.type == 'FONT':
        if obj.name == obj1 : 
            scene.objects[obj2].data.body = obj.data.body

        else :
            scene.objects[obj1].data.body = obj.data.body

bpy.app.handlers.scene_update_pre.append(link_text_objects)
Chebhou
  • 19,533
  • 51
  • 98
  • 1
    Nice! This does what I need! To make it more universal do you think it would be difficult to have it affect any number of selected objects (instead of just two)? – Antti May 09 '15 at 20:45
  • maybe will be done with a group , you may want to check this http://blender.stackexchange.com/a/26722/5113 – Chebhou May 09 '15 at 20:52
2

In case somebody is looking at this with Blender 2.8. @Chebhou's script still works if you replace scene_update_pre with depsgraph_update_pre. So it's this:

import bpy

obj1 = bpy.context.selected_objects[0].name
obj2 = bpy.context.selected_objects[1].name

def link_text_objects(scene):
    obj = bpy.context.active_object
    if obj.type == 'FONT':
        if obj.name == obj1 : 
            scene.objects[obj2].data.body = obj.data.body

        else :
            scene.objects[obj1].data.body = obj.data.body

bpy.app.handlers.depsgraph_update_pre.append(link_text_objects)
0

Following @Chebhou's and @Marc-Chéhab's answers, I adopted this script for any number of selected objects. It should work with Blender 2.8+.

import bpy

objs = [obj.name for obj in bpy.context.selected_objects]

def link_text_objects(scene): obj = bpy.context.active_object if obj.type == 'FONT': for o in [o for o in objs if o != obj.name]: scene.objects[o].data.body = obj.data.body

bpy.app.handlers.depsgraph_update_pre.append(link_text_objects)