From bcd1ab54cd1ebeda433f1c1999f5a9807c808e8e Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sat, 5 Dec 2009 19:27:26 +0000 Subject: Support for the C Macro system in Python. Basic definition works like a python operator but you derive from "bpy.types.Macro" instead. Operators are added to the macro after it has been added with "bpy.ops.add_macro" through the class method "define" which takes an operator id and returns an OperatorMacroType (new RNA type) for which properties can then be defined to be passed to the operator when run. Example: http://blenderartists.org/~theeth/bf/macro.py Using this system, it should be easy to add an operator to the console that converts selected lines into a macro or even a more generic record macro system. --- source/blender/python/intern/bpy_operator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/python/intern/bpy_operator.c') diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 6ae63f2ab65..b4a2fb36a97 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -60,7 +60,7 @@ static PyObject *pyop_call( PyObject * self, PyObject * args) if (!PyArg_ParseTuple(args, "sO|O!i:_bpy.ops.call", &opname, &context_dict, &PyDict_Type, &kw, &context)) return NULL; - ot= WM_operatortype_find(opname, TRUE); + ot= WM_operatortype_exists(opname); if (ot == NULL) { PyErr_Format( PyExc_SystemError, "_bpy.ops.call: operator \"%s\"could not be found", opname); @@ -245,6 +245,8 @@ PyObject *BPY_operator_module( void ) static PyMethodDef pyop_dir_meth = {"dir", (PyCFunction) pyop_dir, METH_NOARGS, NULL}; static PyMethodDef pyop_getrna_meth = {"get_rna", (PyCFunction) pyop_getrna, METH_O, NULL}; static PyMethodDef pyop_add_meth = {"add", (PyCFunction) PYOP_wrap_add, METH_O, NULL}; + static PyMethodDef pyop_add_macro_meth ={"add_macro", (PyCFunction) PYOP_wrap_add_macro, METH_O, NULL}; + static PyMethodDef pyop_macro_def_meth ={"macro_define", (PyCFunction) PYOP_wrap_macro_define, METH_VARARGS, NULL}; static PyMethodDef pyop_remove_meth = {"remove", (PyCFunction) PYOP_wrap_remove, METH_O, NULL}; PyObject *submodule = PyModule_New("_bpy.ops"); @@ -255,6 +257,8 @@ PyObject *BPY_operator_module( void ) PyModule_AddObject( submodule, "dir", PyCFunction_New(&pyop_dir_meth, NULL) ); PyModule_AddObject( submodule, "get_rna", PyCFunction_New(&pyop_getrna_meth, NULL) ); PyModule_AddObject( submodule, "add", PyCFunction_New(&pyop_add_meth, NULL) ); + PyModule_AddObject( submodule, "add_macro", PyCFunction_New(&pyop_add_macro_meth, NULL) ); + PyModule_AddObject( submodule, "macro_define",PyCFunction_New(&pyop_macro_def_meth, NULL) ); PyModule_AddObject( submodule, "remove", PyCFunction_New(&pyop_remove_meth, NULL) ); return submodule; -- cgit v1.2.3