6
$\begingroup$

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.

$\endgroup$
2
  • 1
    $\begingroup$ is that for animation or during editing ? $\endgroup$
    – Chebhou
    Commented May 9, 2015 at 20:09
  • 1
    $\begingroup$ During editing is enough in this case. $\endgroup$
    – Antti
    Commented May 9, 2015 at 20:13

3 Answers 3

7
$\begingroup$

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)
$\endgroup$
2
  • 1
    $\begingroup$ 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)? $\endgroup$
    – Antti
    Commented May 9, 2015 at 20:45
  • $\begingroup$ maybe will be done with a group , you may want to check this blender.stackexchange.com/a/26722/5113 $\endgroup$
    – Chebhou
    Commented May 9, 2015 at 20:52
2
$\begingroup$

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)
$\endgroup$
0
$\begingroup$

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)
$\endgroup$

You must log in to answer this question.

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