Situation: I have a project with 20+ scenes and hundreds of text objects in random places (a song).

Is it possible to put the text object data (text itself) into a text file(s), to edit externally without the need of searching the object inside blender? So that edited and saved text file will update the objects in project on restart of blender?

PS: text objects aren't keyframed (if that makes a change).

  • $\begingroup$ see if this answer helps $\endgroup$
    – Chebhou
    Mar 30 '15 at 15:02
  • $\begingroup$ Hey thanks, it's neat and useful, but it doesn't solve the problem. $\endgroup$
    – markac
    Mar 30 '15 at 18:33
  • $\begingroup$ do you want to export them to individual files then synch them at the end ? $\endgroup$
    – Chebhou
    Mar 30 '15 at 18:34
  • $\begingroup$ Exactly, I was writing this, but it timed me out. xml or csv is also cool. $\endgroup$
    – markac
    Mar 30 '15 at 18:47

This is an addon for writing text objects to .xml file and reading them back from the text file.

How to use:

  • you have a file with text objects in one or multiple scenes
  • have text objects
  • export to an xml file (file->export->text to-from xml )
  • edit text outside blender save the .xml
  • in the first .blend file (with the objects and scenes ) use the addon to update text objects from the .xml file ( this time select read_objects in the left side of the file browser )

enter image description here

install: from the addons tab click install from file and select this txt_xml.py file check the check-box to activate

UPDATE the addon file txt_xml.py

bl_info = {
    "name" : "text objects to-from xml",
    "author" : "chebhou",
    "version" : (1, 0),
    "blender" : (2, 7, 3),
    "location" : "file->export->text to-from xml",
    "discription" : "copys an text objectx from-to xml file",
    "warning" : "this add-on is extremly unusefull",
    "wiki_url" : " chebhou@gmail.com",
    "tracker_url" : "chebhou@gmail.com",
    "category" : "Import-Export"

import bpy
from bpy.types import Operator
from bpy_extras.io_utils import ExportHelper
from bpy.props import EnumProperty, BoolProperty
from xml.dom import minidom
from xml.dom.minidom import Document

def txt_sync(filepath):
    dom = minidom.parse(filepath)
    scenes =dom.getElementsByTagName('scene')
    for scene in scenes:
        bl_scene = bpy.data.scenes[scene_name]
        txt_objs =scene.getElementsByTagName('object')
        for obj in txt_objs:
            obj_name = obj.getAttribute('name')
            obj_body = obj.childNodes[0].nodeValue 
            bl_obj = bl_scene.objects[obj_name].data.body = obj_body
            print(obj_name,"  ",obj_body)

def txt_export(filepath):

    doc = Document()
    root = doc.createElement('data')

    for sce in bpy.data.scenes :
        #create a scene
        scene = doc.createElement('scene')
        scene.setAttribute('name', sce.name)

        for obj in sce.objects :
            if obj.type == 'FONT':   
                #add object element
                object = doc.createElement('object')
                object.setAttribute('name', obj.name)
                txt_node = doc.createTextNode(obj.data.body)

    #write to a file
    file_handle = open(filepath,"wb")

    file_handle.write(bytes(doc.toprettyxml(indent='\t'), 'UTF-8'))

class   text_export(Operator, ExportHelper):  

    """write and read text objects to a file"""        
    bl_idname = "export_scene.text_xml"  
    bl_label = "text from-to xml"     
    bl_options = {'REGISTER', 'UNDO'}    #should remove undo ? 

    # ExportHelper mixin class uses this
    filename_ext = ".xml"

    #parameters and variables
    convert = EnumProperty(
                description="Choose conversion",
                items=(('W', "write objects", "write text objects to xml"),
                       ('R', "read objects", "read text objects from xml")),

    #main function
    def execute(self, context): 
        bpy.ops.object.mode_set(mode = 'OBJECT')
        if self.convert == 'W':

        self.report({'INFO'},"Conversion is Done")
        return {'FINISHED'}

def menu_func_export(self, context):
    self.layout.operator(text_export.bl_idname, text="Text to-from xml")

def register():

def unregister():
if __name__ == "__main__":  
  • $\begingroup$ I am receiving following message ! [error_msg] (pasteall.org/pic/show.php?id=86059). Am I doing something wrong? (I've also tried with blender 2.74) $\endgroup$
    – markac
    Mar 31 '15 at 11:38
  • $\begingroup$ @markac I'll check and be back $\endgroup$
    – Chebhou
    Mar 31 '15 at 11:58
  • $\begingroup$ @markac i have updated the code (the fault was in my code ) remove the old addon and install this one (export fresh file and import it to be sure it is working ) $\endgroup$
    – Chebhou
    Apr 1 '15 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.