In my addon everything is working fine.... other than

bpy.app.driver_namespace["Driver"] = driver

It works if I enable the addon on starting blender, but once I save user preferences, then it seems to not run that line of code but everything else works fine, as far as I can tell

I have tried putting it in classes and in the register function but nothing works


Use a persistent load_post handler to register your drivers to the driver namespace.

import bpy
from bpy.app.handlers import persistent
from bpy.app import driver_namespace as dns

def driver(x):
    return x

def load_handler(dummy):
    print("Load Handler:", bpy.data.filepath)
    #dns = bpy.app.driver_namespace
    # register your drivers
    dns["xdriver"] = driver

def register():

def unregister():

if __name__ == "__main__":

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.