diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-30 05:52:00 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-30 05:52:00 +0400 |
commit | 39ea55fff1e0ce362bb5e9bc958b6d651293e30d (patch) | |
tree | c94e2c02e60428d7d4115538ece8a749016501ae /source/blender/python | |
parent | 24a269a07c150d449363b455d4de89a88151d651 (diff) |
Operator Copy/Paste
you can copy operator strings from buttons or the reporting interface and run them in the console.
- Ctrl+C over an operator button copies its python string to the clipboard.
- Paste in the console (1 line only for now).
- operators run from python no longer require all arguments.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_operator.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 31 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.h | 2 |
3 files changed, 18 insertions, 17 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 2ffa9db4027..034440d77ac 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -95,7 +95,7 @@ static PyObject *pyop_call( PyObject * self, PyObject * args) RNA_pointer_create(NULL, ot->srna, NULL, &ptr); if(kw && PyDict_Size(kw)) - error_val= pyrna_pydict_to_props(&ptr, kw, "Converting py args to operator properties: "); + error_val= pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: "); if (error_val==0) { diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 91e443dbc93..27bfb89b963 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -375,9 +375,9 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) return ret; } -/* This function is only used by operators right now - * Its used for taking keyword args and filling in property values */ -int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, const char *error_prefix) +/* This function is used by operators and converting dicts into collections. + * Its takes keyword args and fills them with property values */ +int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const char *error_prefix) { int error_val = 0; int totkw; @@ -397,20 +397,21 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, const char *error_prefi break; } - item= PyDict_GetItemString(kw, arg_name); + item= PyDict_GetItemString(kw, arg_name); /* wont set an error */ if (item == NULL) { - PyErr_Format( PyExc_TypeError, "%.200s: keyword \"%.200s\" missing", error_prefix, arg_name ? arg_name : "<UNKNOWN>"); - error_val = -1; /* pyrna_py_to_prop sets the error */ - break; - } - - if (pyrna_py_to_prop(ptr, prop, NULL, item, error_prefix)) { - error_val= -1; - break; + if(all_args) { + PyErr_Format( PyExc_TypeError, "%.200s: keyword \"%.200s\" missing", error_prefix, arg_name ? arg_name : "<UNKNOWN>"); + error_val = -1; /* pyrna_py_to_prop sets the error */ + break; + } + } else { + if (pyrna_py_to_prop(ptr, prop, NULL, item, error_prefix)) { + error_val= -1; + break; + } + totkw--; } - - totkw--; } RNA_STRUCT_END; @@ -753,7 +754,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v else RNA_property_collection_add(ptr, prop, &itemptr); - if(pyrna_pydict_to_props(&itemptr, item, "Converting a python list to an RNA collection")==-1) { + if(pyrna_pydict_to_props(&itemptr, item, 1, "Converting a python list to an RNA collection")==-1) { Py_DECREF(item); return -1; } diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 76e4a13c167..9138fd511b0 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -70,7 +70,7 @@ PyObject *pyrna_prop_CreatePyObject( PointerRNA *ptr, PropertyRNA *prop ); /* operators also need this to set args */ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix); -int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, const char *error_prefix); +int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const char *error_prefix); PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop); /* functions for setting up new props - experemental */ |