diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-11-27 05:39:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-11-27 05:39:51 +0300 |
commit | 02cc80691d71ea305780655d3b0d4cd4530db9c7 (patch) | |
tree | f41d0aeb97e5667d4697c2a90b7fc2becc65ffa6 /source/blender/windowmanager | |
parent | 4a804855b26bd764b7752e673052c0001dce32a1 (diff) |
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.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ba601a65ad5..d2c1a2dc0dc 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -319,6 +319,7 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports) #ifdef WITH_PYTHON /* run any texts that were loaded in and flagged as modules */ + BPY_reset_driver(); BPY_load_user_modules(C); #endif CTX_wm_window_set(C, NULL); /* exits queues */ @@ -410,6 +411,9 @@ int WM_read_homefile(bContext *C, wmOperator *op) if(CTX_py_init_get(C)) { /* sync addons, these may have changed from the defaults */ BPY_eval_string(C, "__import__('bpy').utils.addon_reset_all()"); + + BPY_reset_driver(); + BPY_load_user_modules(C); } #endif diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 855317b9f76..f75a1c0fb7f 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -146,6 +146,8 @@ void WM_init(bContext *C, int argc, char **argv) #ifdef WITH_PYTHON BPY_set_context(C); /* necessary evil */ BPY_start_python(argc, argv); + + BPY_reset_driver(); BPY_load_user_modules(C); #else (void)argc; /* unused */ |