Custom "pydrivers.py" Python Library Not Accessible from Drivers

Hi,

I want to use custom python expressions to control my drivers.

I read here that if I have some text open in blender that is named “pydrivers.py” I can define my own functions and access them by typing “p.myfunction(arg)” in the python expression block.
That’s really cool, but I followed all of the instructions ( or so think ), and Blender will not accept any of my custom functions.

I’ve noticed that the documentation talks about how you can access math functions by typing m.pi() or m.sin() etc, but this isn’t exactly true. The math libraries are imported, but are not accessed the way it says. It only lets me access them by simply typing “sin()” or “pi” without the preceding “m.”. Is this related to my problem? Do I have to access my functions with a different syntax? I’ve tried accessing my functions with and without the preceding “p.” and neither works.

Is there anyone out there who can help?

Ok, I think I found my answer. It would seem that the documentation I previously linked to is out of date.

I’m not sure, it looks like the pydrivers.py trick is obsolete and instead you should follow the instructions posted here:

If I code this in a Blender python module, I can define and access whatever I want.

def foo():
# Do stuff
return bla
bpy.app.driver_namespace[‘foo’] = foo