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-05-25 05:45:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-05-25 05:45:35 +0400
commit3ceed4cfb207e06c978d49f2992f8a19970cab22 (patch)
tree0c12b6a10e58709196a4b5eb4f33e8fed4630304
parent1266e0f2bffb95a59157075f9f4f071dcc744f73 (diff)
[#18731] trouble with the python api in assigning script constraint's target.
- Setting the constraint script from python didnt update the target count - Setting objects didnt work at all, since it checked the input sequence for being an BPy_Object type (rather then an item in the sequence)
-rw-r--r--source/blender/python/api2_2x/Constraint.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/source/blender/python/api2_2x/Constraint.c b/source/blender/python/api2_2x/Constraint.c
index 9ecec8eb973..ae96627cc2f 100644
--- a/source/blender/python/api2_2x/Constraint.c
+++ b/source/blender/python/api2_2x/Constraint.c
@@ -52,6 +52,7 @@
#include "blendef.h"
#include "mydevice.h"
+#include "../BPY_extern.h" // BPY_pyconstraint_update
#include "IDProp.h"
#include "Object.h"
#include "NLA.h"
@@ -1498,6 +1499,11 @@ static int script_setter( BPy_Constraint *self, int type, PyObject *value )
bConstraintTarget *ct;
int ok= 0;
+ if (PySequence_Check(value) == 0 || PyString_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "expected a sequence of strings or blender");
+ return -1;
+ }
+
if (cti) {
/* change space of targets */
if (cti->get_constraint_targets) {
@@ -1506,13 +1512,12 @@ static int script_setter( BPy_Constraint *self, int type, PyObject *value )
/* get targets, and extract values from the given list */
num_tars= cti->get_constraint_targets(self->con, &targets);
+ if ((PySequence_Size(value) != num_tars)) {
+ PyErr_Format(PyExc_TypeError, "expected sequence of strings or blender objects - %d length", num_tars);
+ return -1;
+ }
+
if (num_tars) {
- if ((PySequence_Check(value) == 0) || (PySequence_Size(value) != num_tars)) {
- char errorstr[64];
- sprintf(errorstr, "expected sequence of %d integer(s)", num_tars);
- return EXPP_ReturnIntError(PyExc_TypeError, errorstr);
- }
-
for (ct=targets.first; ct; ct=ct->next, i++) {
PyObject *val= PySequence_ITEM(value, i);
@@ -1530,10 +1535,11 @@ static int script_setter( BPy_Constraint *self, int type, PyObject *value )
BLI_strncpy(ct->subtarget, name, sizeof(ct->subtarget));
}
- else {
+ else /* if EXPP_CONSTR_TARGET */ {
+
Object *obj = (( BPy_Object * )val)->object;
- if ( !BPy_Object_Check(value) ) {
+ if ( !BPy_Object_Check(val) ) {
// hrm... should we break here instead?
ok = EXPP_ReturnIntError(PyExc_TypeError,
"expected BPy object argument as member of list");
@@ -1564,6 +1570,7 @@ static int script_setter( BPy_Constraint *self, int type, PyObject *value )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected BPy text argument" );
con->text = text;
+ BPY_pyconstraint_update(self->obj, self->con);
return 0;
}
case EXPP_CONSTR_PROPS: