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>2005-10-31 17:05:47 +0300
committerKen Hughes <khughes@pacific.edu>2005-10-31 17:05:47 +0300
commit7040e6c157b53c844dc9e0a0c895f4a2167520cb (patch)
tree7756d7a24d9b5801d515e1153e027470b4402a42 /source/blender/python/api2_2x/Ipo.c
parentf2ff00b97f530858f26fce320a3b2ac908c536ce (diff)
-- patch submitted by Johnny Matthews which lets a user get an Ipo curve by
its adrcode in addition to its string name (shape keys don't have fixed or unique string names, and they are stored in the key, not the Ipo). This will make it easier to later use constants from dictionaries to access a curve.
Diffstat (limited to 'source/blender/python/api2_2x/Ipo.c')
-rw-r--r--source/blender/python/api2_2x/Ipo.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c
index 02a7749c59d..f0dffe3f0e5 100644
--- a/source/blender/python/api2_2x/Ipo.c
+++ b/source/blender/python/api2_2x/Ipo.c
@@ -970,22 +970,34 @@ static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args )
static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args )
{
- char *str, *str1;
- IpoCurve *icu = 0;
-
- if( !PyArg_ParseTuple( args, "s", &str ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_TypeError, "expected string argument" ) );
-
- for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
- str1 = getIpoCurveName( icu );
- if( !strcmp( str1, str ) )
- return IpoCurve_CreatePyObject( icu );
- }
-
- Py_INCREF( Py_None );
- return Py_None;
-}
+ char *str, *str1;
+ IpoCurve *icu = NULL;
+ int adrcode;
+ PyObject *thing;
+
+ if( !PyArg_ParseTuple( args, "O", &thing ) )
+ return EXPP_ReturnPyObjError(PyExc_TypeError,
+ "expected string or int argument" );
+
+ if(PyString_Check(thing)){
+ str = PyString_AsString(thing);
+ for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
+ str1 = getIpoCurveName( icu );
+ if( !strcmp( str1, str ) )
+ return IpoCurve_CreatePyObject( icu );
+ }
+ } else if (PyInt_Check(thing)){
+ adrcode = (short)PyInt_AsLong(thing);
+ for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
+ if(icu->adrcode == adrcode)
+ return IpoCurve_CreatePyObject( icu );
+ }
+ } else
+ return EXPP_ReturnPyObjError(PyExc_TypeError,
+ "expected string or int argument" );
+ Py_INCREF( Py_None );
+ return Py_None;
+}
static PyObject *Ipo_getCurves( BPy_Ipo * self )
{