If you ever used BlenRig, you may have noticed that it pops up a text file in your text editor called "generate_customprops.py". This is a python script that the rig uses for various purposes such as automatically disabling drivers and hiding bones. When you append a BlenRig rig to another file, this text file comes with it.

I also need to execute some python script in my own custom rig, and I also have a text file. The functions in the script can be called from any Driver. All of this works fine and opens a lot of new possibilities for what a rig can do. However, if I try to append my rig to another blend file, the text file will not come with it, and has to be appended separately. Since I'm trying to create public rigs for other people to use, this is not ideal. Any help would be appreciated!


3 Answers 3


Blender 4.0 and above
The ability to create Datablock pointer custom properties has been added to Blender's UI. You can simply add a Custom Property, set its type to Datablock, and then the datablock type to Text. Then just select your script. Datablock custom property Now, when you link or append this object, the text datablock will come along with it.

Blender 3.6 and below

Custom Properties can store datablock references. This can only be done via Python until Blender 4.0, but it's just a one-liner in the console. With your object selected, put this in the console:
bpy.context.object['my_script'] = bpy.data.texts['my_script.py']

The textfile is now a dependency of the object, and will be appended when the object is appended.



Another method would be to associate the text with the armature object or armature itself using a bpy.props.PointerProperty(type=bpy.types.Text)

import bpy
from bpy.props import PointerProperty

bpy.types.Armature.script_file = PointerProperty(type=bpy.types.Text)

As shown in this answer can poll the property. Another test script with a sample UI panel and the text associated to an armature object.

import bpy    

class OBJECT_PT_HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    #poll for armature object
    def poll(cls, context):
        return context.object and context.object.type == 'ARMATURE'

    def draw(self, context):
        layout = self.layout
        arm_ob = context.object
        layout.prop(arm_ob, "rig_script")

def is_armature_object(self, object):
    return self.type == 'ARMATURE'

def register():
    bpy.types.Object.rig_script = bpy.props.PointerProperty(

def unregister():
    del bpy.types.Object.rig_script

if __name__ == "__main__":

Solution for Blender 2.79 and below
Driver variables can reference text files.

In your driver(any driver that is part of your rig) add a new variable with Single Property type. Then by clicking on the object icon, you can select (almost?) any data type that exists in Blender. Including text files! Driver variable


You must log in to answer this question.

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