I have a method x which I can add to the driver namespace like this:

bpy.app.driver_namespace["x"] = x

but the namespace is reset everytime I restart Blender, which then messes up my drivers. Is there a way to permanently add it to the namespace or auto-execute this script when starting Blender?


Put this code into a Python file and place it into ~/.config/blender/2.78/scrips/startup/my_driver_stuff.py (replace ~/config/blender with %APPDATA%/Blender Foundation/Blender on Windows, and something along those lines on MacOS).

import bpy

def setup_driver(*args):
    bpy.app.driver_namespace["x"] = x
| improve this answer | |
  • $\begingroup$ ok now that's weird... It created a "pycache" folder in the startup folder, presumably containing the compiled script. But the method is still not in the namespace... $\endgroup$ – Xerus Jul 12 '17 at 23:48
  • $\begingroup$ I've updated my answer to use a load_post handler. Haven't tried it myself, but it should work like this ;-) $\endgroup$ – dr. Sybren Jul 13 '17 at 20:22

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.