diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-10-23 03:23:09 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-10-23 03:23:09 +0400 |
commit | caa27f09fd19a5d37ae7775b8c80246bd7befe13 (patch) | |
tree | 5e66085ed3e2047f461f250152fcb1f4a9b36524 /source/blender/python/intern/bpy_interface.c | |
parent | e8af794441bbce7ef49d872e8c3b2c2b7971e0e6 (diff) |
Bugfixes:
* The python 'math' library is now included in the py-namespace used to evaluate button expressions. So it is now possible to do 'radians(somevalue)' to get a rotation value that Blender can understand...
* Shapekey path getting function now uses the appropriate wrapper for grabbing the pointer to the ID block for the ShapeKey
* Made the Graph Editor's minimum zoom size finer...
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 9e76c1d03aa..095bfab45c4 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -884,7 +884,7 @@ float BPY_pydriver_eval (ChannelDriver *driver) int BPY_button_eval(bContext *C, char *expr, double *value) { PyGILState_STATE gilstate; - PyObject *dict, *retval; + PyObject *dict, *mod, *retval; int error_ret = 0; if (!value || !expr || expr[0]=='\0') return -1; @@ -892,6 +892,20 @@ int BPY_button_eval(bContext *C, char *expr, double *value) bpy_context_set(C, &gilstate); dict= CreateGlobalDictionary(C); + + /* import some modules: builtins,math*/ + PyDict_SetItemString(dict, "__builtins__", PyEval_GetBuiltins()); + + mod = PyImport_ImportModule("math"); + if (mod) { + PyDict_Merge(dict, PyModule_GetDict(mod), 0); /* 0 - dont overwrite existing values */ + + /* Only keep for backwards compat! - just import all math into root, they are standard */ + PyDict_SetItemString(dict, "math", mod); + PyDict_SetItemString(dict, "m", mod); + Py_DECREF(mod); + } + retval = PyRun_String(expr, Py_eval_input, dict, dict); if (retval == NULL) { |