python access to driver namespace, rather then have a textblock defined for drivers...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 27 Nov 2010 02:39:51 +0000 (02:39 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 27 Nov 2010 02:39:51 +0000 (02:39 +0000)
commit02cc80691d71ea305780655d3b0d4cd4530db9c7
treef41d0aeb97e5667d4697c2a90b7fc2becc65ffa6
parent4a804855b26bd764b7752e673052c0001dce32a1
python access to driver namespace, rather then have a textblock defined for drivers allow scripts to add functions directly.
- bpy.app.driver_namespace, read-only dictionary, edit in-place.
- reset on file load and new file.
- on errors the namespace used to be reset, this should not be needed.

simple example.

  def driverFunc(val):
    return val * val
  bpy.app.driver_namespace['driverFunc'] = driverFunc

... now all drivers can access this function.
source/blender/python/BPY_extern.h
source/blender/python/intern/bpy_app.c
source/blender/python/intern/bpy_app.h
source/blender/python/intern/bpy_driver.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/creator/creator.c