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:
authorKen Hughes <khughes@pacific.edu>2006-05-12 08:34:02 +0400
committerKen Hughes <khughes@pacific.edu>2006-05-12 08:34:02 +0400
commitd6bad3e2362772f9430ba6fd386be723667ba709 (patch)
tree8325a42aeab97fcf6b79834f46e7247f68388134 /source/blender/python/api2_2x
parent4b4029afaf399ab5951ca237e8b5368013cc0411 (diff)
===Python API===
Added NULL constraint (and fixed bug that didn't allow appending FLOOR constraint), and added support for Constraint.Settings.LOCAL key support in COPYLOC, COPYROT and COPYSIZE constraints when target object is an armature.
Diffstat (limited to 'source/blender/python/api2_2x')
-rw-r--r--source/blender/python/api2_2x/Constraint.c33
-rw-r--r--source/blender/python/api2_2x/doc/Constraint.py3
2 files changed, 34 insertions, 2 deletions
diff --git a/source/blender/python/api2_2x/Constraint.c b/source/blender/python/api2_2x/Constraint.c
index 5572411ea85..8fcb155c9d6 100644
--- a/source/blender/python/api2_2x/Constraint.c
+++ b/source/blender/python/api2_2x/Constraint.c
@@ -41,6 +41,7 @@
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_action.h"
+#include "BKE_armature.h"
#include "BLI_blenlib.h"
#include "BIF_editconstraint.h"
#include "BSE_editipo.h"
@@ -826,6 +827,10 @@ static PyObject *locatelike_getter( BPy_Constraint * self, int type )
return PyString_FromString( con->subtarget );
case EXPP_CONSTR_COPY:
return PyInt_FromLong( (long)con->flag );
+ case EXPP_CONSTR_LOCAL:
+ if( get_armature( con->tar ) )
+ return PyBool_FromLong( (long)( self->con->flag & CONSTRAINT_LOCAL ) ) ;
+ Py_RETURN_NONE;
default:
return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
}
@@ -857,6 +862,12 @@ static int locatelike_setter( BPy_Constraint *self, int type, PyObject *value )
case EXPP_CONSTR_COPY:
return EXPP_setIValueRange( value, &con->flag,
0, LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z, 'i' );
+ case EXPP_CONSTR_LOCAL:
+ if( !get_armature( con->tar ) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "only armature targets have LOCAL key" );
+ return EXPP_setBitfield( value, &self->con->flag,
+ CONSTRAINT_LOCAL, 'h' );
default:
return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
}
@@ -873,6 +884,10 @@ static PyObject *rotatelike_getter( BPy_Constraint * self, int type )
return PyString_FromString( con->subtarget );
case EXPP_CONSTR_COPY:
return PyInt_FromLong( (long)con->flag );
+ case EXPP_CONSTR_LOCAL:
+ if( get_armature( con->tar ) )
+ return PyBool_FromLong( (long)( self->con->flag & SELECT ) ) ;
+ Py_RETURN_NONE;
default:
return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
}
@@ -904,6 +919,11 @@ static int rotatelike_setter( BPy_Constraint *self, int type, PyObject *value )
case EXPP_CONSTR_COPY:
return EXPP_setIValueRange( value, &con->flag,
0, LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z, 'i' );
+ case EXPP_CONSTR_LOCAL:
+ if( !get_armature( con->tar ) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "only armature targets have LOCAL key" );
+ return EXPP_setBitfield( value, &self->con->flag, SELECT, 'h' );
default:
return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
}
@@ -920,6 +940,10 @@ static PyObject *sizelike_getter( BPy_Constraint * self, int type )
return PyString_FromString( con->subtarget );
case EXPP_CONSTR_COPY:
return PyInt_FromLong( (long)con->flag );
+ case EXPP_CONSTR_LOCAL:
+ if( get_armature( con->tar ) )
+ return PyBool_FromLong( (long)( self->con->flag & SELECT ) ) ;
+ Py_RETURN_NONE;
default:
return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
}
@@ -951,6 +975,11 @@ static int sizelike_setter( BPy_Constraint *self, int type, PyObject *value )
case EXPP_CONSTR_COPY:
return EXPP_setIValueRange( value, &con->flag,
0, LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z, 'i' );
+ case EXPP_CONSTR_LOCAL:
+ if( !get_armature( con->tar ) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "only armature targets have LOCAL key" );
+ return EXPP_setBitfield( value, &self->con->flag, SELECT, 'h' );
default:
return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
}
@@ -1052,6 +1081,8 @@ static int Constraint_setData( BPy_Constraint * self, PyObject * key,
case CONSTRAINT_TYPE_SIZELIKE:
result = sizelike_setter( self, key_int, arg );
break;
+ case CONSTRAINT_TYPE_NULL:
+ return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
case CONSTRAINT_TYPE_CHILDOF: /* Unimplemented */
case CONSTRAINT_TYPE_ROTLIMIT:
case CONSTRAINT_TYPE_LOCLIMIT:
@@ -1236,7 +1267,7 @@ static PyObject *ConstraintSeq_append( BPy_ConstraintSeq *self, PyObject *args )
EXPP_ReturnPyObjError( PyExc_TypeError, "expected int argument" );
/* type 0 is CONSTRAINT_TYPE_NULL, should we be able to add one of these? */
- if( type <= CONSTRAINT_TYPE_NULL || type >= CONSTRAINT_TYPE_MINMAX )
+ if( type < CONSTRAINT_TYPE_NULL || type > CONSTRAINT_TYPE_MINMAX )
return EXPP_ReturnPyObjError( PyExc_ValueError,
"int argument out of range" );
diff --git a/source/blender/python/api2_2x/doc/Constraint.py b/source/blender/python/api2_2x/doc/Constraint.py
index bdc5e56728c..be42bd7e2b1 100644
--- a/source/blender/python/api2_2x/doc/Constraint.py
+++ b/source/blender/python/api2_2x/doc/Constraint.py
@@ -31,7 +31,7 @@ Or to print all the constraints attached to each bone in a pose::
@var Type: Constant Constraint dict used by L{ConstraintSeq.append()} and
for comparison with L{Constraint.type}. Values are
TRACKTO, IKSOLVER, FOLLOWPATH, COPYROT, COPYLOC, COPYSIZE, ACTION,
- LOCKTRACK, STRETCHTO, FLOOR
+ LOCKTRACK, STRETCHTO, FLOOR, NULL
@type Settings: readonly dictionary
@var Settings: Constant dict used for changing constraint settings.
@@ -82,6 +82,7 @@ Or to print all the constraints attached to each bone in a pose::
- Used by Copy Location (COPYLOC), Copy Rotation (COPYROT), and Copy Size
(COPYSIZE) constraint:
- COPY (bitfield): any combination of COPYX, COPYY and COPYZ
+ - LOCAL (bool): Only for constraints which Armature targets.
"""