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>2008-12-21 11:53:36 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-12-21 11:53:36 +0300
commit4a86a07f8a8344ce7bd0dce02d8902e33d652a1a (patch)
treee56973a3da689b78c661af594bc705cd301cfbef /source/blender/python/intern/bpy_interface.c
parent449e7777f75fa030894e89bd7d6a5daa9b9502b3 (diff)
wip operator py-api
"operator.ED_VIEW3D_OT_viewhome(center=1)" calls the operator, converting keyword args to properties. Need a way to run scripts in the UI for useful testing. Still need to deal with operator exceptions and verifying args against operator options. Added temporary WM_operatortype_first() to allow python to return a list if available operators, can replace this with something better later (operator iterator?)
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r--source/blender/python/intern/bpy_interface.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index d30809ff39b..7c54c728a05 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -3,16 +3,19 @@
#include "compile.h" /* for the PyCodeObject */
#include "eval.h" /* for PyEval_EvalCode */
+#include "BKE_context.h"
+
#include "bpy_compat.h"
#include "bpy_rna.h"
+#include "bpy_operator.h"
/*****************************************************************************
* Description: This function creates a new Python dictionary object.
*****************************************************************************/
-static PyObject *CreateGlobalDictionary( void )
+static PyObject *CreateGlobalDictionary( bContext *C )
{
PyObject *dict = PyDict_New( );
PyObject *item = PyUnicode_FromString( "__main__" );
@@ -28,6 +31,10 @@ static PyObject *CreateGlobalDictionary( void )
item = BPY_rna_doc();
PyDict_SetItemString( dict, "bpydoc", item );
Py_DECREF(item);
+
+ item = BPY_operator_module(C);
+ PyDict_SetItemString( dict, "bpyoperator", item );
+ Py_DECREF(item);
return dict;
}
@@ -60,7 +67,7 @@ static void BPY_end_python( void )
return;
}
-void BPY_run_python_script( const char *fn )
+void BPY_run_python_script( bContext *C, const char *fn )
{
PyObject *py_dict, *py_result;
char pystring[512];
@@ -73,7 +80,7 @@ void BPY_run_python_script( const char *fn )
gilstate = PyGILState_Ensure();
- py_dict = CreateGlobalDictionary();
+ py_dict = CreateGlobalDictionary(C);
py_result = PyRun_String( pystring, Py_file_input, py_dict, py_dict );