Modification of the function getCurvecurval suggested by Jiba. This function can take an integer argument (the position of the curve) or a string (the name of the curve)

Updated documentation in doc/Ipo.py
This commit is contained in:
Jacques Guignot 2003-12-17 14:15:14 +00:00
parent ed67092601
commit 4b813c5c81
2 changed files with 27 additions and 15 deletions

@ -344,7 +344,7 @@ static PyObject *Ipo_addCurve(BPy_Ipo *self, PyObject *args)
IpoCurve *ptr; IpoCurve *ptr;
int typenumber = -1; int typenumber = -1;
char*type = 0; char*type = 0;
static char *name="mmm"; static char *name="mmmppp";
if (!PyArg_ParseTuple(args, "s",&type)) if (!PyArg_ParseTuple(args, "s",&type))
return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument")); return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument"));
@ -549,20 +549,32 @@ static PyObject *Ipo_EvaluateCurveOn(BPy_Ipo *self, PyObject *args)
static PyObject *Ipo_getCurvecurval(BPy_Ipo *self, PyObject *args) static PyObject *Ipo_getCurvecurval(BPy_Ipo *self, PyObject *args)
{ {
int num = 0,i; int numcurve = 0,i;
IpoCurve *icu; IpoCurve *icu;
char*stringname = 0;
if (!PyArg_ParseTuple(args, "i",&num)) if (!PyArg_ParseTuple(args, "i",&numcurve))
return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected int argument")); if (!PyArg_ParseTuple(args, "s",&stringname))
return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected int or string argument"));
icu =self->ipo->curve.first; icu =self->ipo->curve.first;
if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve"));
for(i = 0;i<num;i++) if (!stringname)
for(i = 0;i<numcurve;i++)
{ {
puts(type_from_num(icu->adrcode,icu->blocktype));
if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"Bad ipo number")); if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"Bad ipo number"));
icu=icu->next; icu=icu->next;
} }
return PyFloat_FromDouble(icu->curval); else
while (icu){
if (!strcmp(type_from_num(icu->adrcode,icu->blocktype),stringname))break;
icu=icu->next;
}
if (icu) return PyFloat_FromDouble(icu->curval);
else { Py_INCREF(Py_None);
return Py_None;
}
} }

@ -151,8 +151,8 @@ class Ipo:
def getCurvecurval(curvepos): def getCurvecurval(curvepos):
""" """
Gets the current value of a curve of the Ipo. Gets the current value of a curve of the Ipo.
@type curvepos: int @type curvepos: int or string
@param curvepos: the position of the curve in the ipo @param curvepos: the position of the curve in the ipo or the name of the curve
@rtype: float @rtype: float
@return: the current value of the selected curve of the Ipo. @return: the current value of the selected curve of the Ipo.
""" """