Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-10-29 12:25:11 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-10-29 12:25:11 +0300
commitc508e6198a614619bb9d82cd59c0fdb7f55f427d (patch)
treebda1b4de7fbc1ef951f4bf49dfd440086902613a /source/blender/blenkernel/intern/context.c
parent40731af9d0b85e3cf93e46e48b814faa06aac74b (diff)
Python can now run operators with their own context (data context).
The aim of this is to avoid having to set the selection each time before running an operator from python. At the moment this is set as a python dictionary with string keys and rna values... eg. C = {} C["active_object"] = bpy.data.objects['SomeOb'] bpy.ops.object.game_property_new(C) # ofcourse this works too.. bpy.ops.object.game_property_new({"active_object":ob}) # or... C = {"main":bpy.data, "scene":bpy.data.scenes[0], "active_object":bpy.data.objects['SomeOb'], "selected_editable_objects":list(bpy.data.objects)} bpy.ops.object.location_apply(C)
Diffstat (limited to 'source/blender/blenkernel/intern/context.c')
-rw-r--r--source/blender/blenkernel/intern/context.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index d5cc31d918a..7f2872c0797 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -71,6 +71,7 @@ struct bContext {
int recursion;
int py_init; /* true if python is initialized */
+ void *py_context;
} data;
/* data evaluation */
@@ -175,6 +176,15 @@ void CTX_py_init_set(bContext *C, int value)
C->data.py_init= value;
}
+void *CTX_py_dict_get(bContext *C)
+{
+ return C->data.py_context;
+}
+void CTX_py_dict_set(bContext *C, void *value)
+{
+ C->data.py_context= value;
+}
+
/* window manager context */
wmWindowManager *CTX_wm_manager(const bContext *C)
@@ -401,6 +411,10 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
memset(result, 0, sizeof(bContextDataResult));
+ if(CTX_py_dict_get(C)) {
+ return bpy_context_get(C, member, result);
+ }
+
/* we check recursion to ensure that we do not get infinite
* loops requesting data from ourselfs in a context callback */
if(!done && recursion < 1 && C->wm.store) {