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-11-25 13:13:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-25 13:13:24 +0300
commitc410a0e8552878adbeda41621dfb00663657fc61 (patch)
treecfdcece8c9865d54ce7a3a656b70e32bdbbeeae3 /source/blender/python
parent802779eb2d266f6a1de717fe9e7dcadc9774a7d3 (diff)
rna py api,
generic rna function driver_add(), now returns the driver added (or a list of drivers if all channels are set)
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 56981e0fe0a..fd5e1ddf75c 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -39,6 +39,9 @@
#include "BKE_global.h" /* evil G.* */
#include "BKE_report.h"
+#include "BKE_animsys.h"
+#include "BKE_fcurve.h"
+
/* only for keyframing */
#include "DNA_scene_types.h"
#include "DNA_anim_types.h"
@@ -1358,7 +1361,7 @@ static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
char *path, *path_full;
int index= -1; /* default to all */
PropertyRNA *prop;
- PyObject *result;
+ PyObject *ret;
if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index))
return NULL;
@@ -1387,10 +1390,38 @@ static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
return NULL;
}
- result= PyBool_FromLong( ANIM_add_driver((ID *)self->ptr.id.data, path_full, index, 0, DRIVER_TYPE_PYTHON));
+ if(ANIM_add_driver((ID *)self->ptr.id.data, path_full, index, 0, DRIVER_TYPE_PYTHON)) {
+ ID *id= self->ptr.id.data;
+ AnimData *adt= BKE_animdata_from_id(id);
+ FCurve *fcu;
+
+ PointerRNA tptr;
+ PyObject *item;
+
+ if(index == -1) { /* all, use a list */
+ int i= 0;
+ ret= PyList_New(0);
+ while((fcu= list_find_fcurve(&adt->drivers, path_full, i++))) {
+ RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
+ item= pyrna_struct_CreatePyObject(&tptr);
+ PyList_Append(ret, item);
+ Py_DECREF(item);
+ }
+ }
+ else {
+ fcu= list_find_fcurve(&adt->drivers, path_full, index);
+ RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
+ ret= pyrna_struct_CreatePyObject(&tptr);
+ }
+ }
+ else {
+ ret= Py_None;
+ Py_INCREF(ret);
+ }
+
MEM_freeN(path_full);
- return result;
+ return ret;
}
static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *args)