Python API fixes. Provided by Anders Nilsson (breakin)

* Typo fixed in IpoCurve_getInterpolation.
  'Bonstant' was used, while 'Constant' is what we want.
* IpoCurve.getName now also returns curve names for action-IPOs.

* Update to the Object module:
  Added obj.getTimeOffset() and obj.setTimeOffset() methods

Anders Nilsson has promissed me to provide some updated Python API docs :)
This commit is contained in:
Michel Selten 2004-04-02 18:38:38 +00:00
parent 8e5fd5bba3
commit 7cc4d7525d
2 changed files with 76 additions and 20 deletions

@ -224,7 +224,7 @@ IpoCurve_getInterpolation (C_IpoCurve * self)
if (icu->ipo == IPO_BEZ) if (icu->ipo == IPO_BEZ)
str = "Bezier"; str = "Bezier";
if (icu->ipo == IPO_CONST) if (icu->ipo == IPO_CONST)
str = "Bonstant"; str = "Constant";
if (icu->ipo == IPO_LIN) if (icu->ipo == IPO_LIN)
str = "Linear"; str = "Linear";
@ -341,27 +341,50 @@ IpoCurve_Recalc (C_IpoCurve * self)
static PyObject * static PyObject *
IpoCurve_getName (C_IpoCurve * self) IpoCurve_getName (C_IpoCurve * self)
{ {
char *nametab[24] = const int objectType=self->ipocurve->blocktype;
{ "LocX", "LocY", "LocZ", "dLocX", "dLocY", "dLocZ", "RotX", "RotY", const int trackType=self->ipocurve->adrcode;
"RotZ", "dRotX", "dRotY", "dRotZ", "SizeX", "SizeY", "SizeZ", "dSizeX",
"dSizeY",
"dSizeZ", "Layer", "Time", "ColR", "ColG", "ColB", "ColA"
};
if (self->ipocurve->blocktype != ID_OB) const char * ob_nametab[24] = {"LocX","LocY","LocZ","dLocX","dLocY","dLocZ",
"RotX","RotY","RotZ","dRotX","dRotY","dRotZ","SizeX","SizeY","SizeZ",
"dSizeX","dSizeY","dSizeZ","Layer","Time","ColR","ColG","ColB","ColA"};
const char * ac_nametab[5] = {"QuatW", "QuatX", "QuatY", "QuatZ","TotIpo"};
switch (objectType) {
case ID_OB: {
if (self->ipocurve->adrcode <= 0 ) {
return PyString_FromString("Index too small");
} else if (self->ipocurve->adrcode >= 25 ) {
return PyString_FromString("Index too big");
} else {
return PyString_FromString(ob_nametab[trackType-1]);
}
}
break;
case ID_AC: {
switch (trackType) {
case 1: case 2: case 3: case 13: case 14: case 15:
return PyString_FromString(ob_nametab[trackType-1]);
break;
case 25: case 26: case 27: case 28:
return PyString_FromString(ac_nametab[trackType-25]);
break;
case 10:
return PyString_FromString(ac_nametab[4]);
break;
default:
return PyString_FromString("Index out of range");
}
}
break;
default:
return EXPP_ReturnPyObjError (PyExc_TypeError, return EXPP_ReturnPyObjError (PyExc_TypeError,
"This function doesn't support this ipocurve type yet"); "This function doesn't support this ipocurve type yet");
// printf("IpoCurve_getName %d\n",self->ipocurve->vartype);
if (self->ipocurve->adrcode <= 0)
return PyString_FromString ("Index too small");
if (self->ipocurve->adrcode >= 25)
return PyString_FromString ("Index too big");
return PyString_FromString (nametab[self->ipocurve->adrcode - 1]);
} }
}
static void static void
IpoCurveDeAlloc (C_IpoCurve * self) IpoCurveDeAlloc (C_IpoCurve * self)

@ -102,6 +102,7 @@ static PyObject *Object_getMatrix (BPy_Object *self);
static PyObject *Object_getName (BPy_Object *self); static PyObject *Object_getName (BPy_Object *self);
static PyObject *Object_getParent (BPy_Object *self); static PyObject *Object_getParent (BPy_Object *self);
static PyObject *Object_getSize (BPy_Object *self, PyObject *args); static PyObject *Object_getSize (BPy_Object *self, PyObject *args);
static PyObject *Object_getTimeOffset (BPy_Object *self);
static PyObject *Object_getTracked (BPy_Object *self); static PyObject *Object_getTracked (BPy_Object *self);
static PyObject *Object_getType (BPy_Object *self); static PyObject *Object_getType (BPy_Object *self);
static PyObject *Object_getBoundBox (BPy_Object *self); static PyObject *Object_getBoundBox (BPy_Object *self);
@ -119,6 +120,7 @@ static PyObject *Object_setLocation (BPy_Object *self, PyObject *args);
static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args); static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args);
static PyObject *Object_setName (BPy_Object *self, PyObject *args); static PyObject *Object_setName (BPy_Object *self, PyObject *args);
static PyObject *Object_setSize (BPy_Object *self, PyObject *args); static PyObject *Object_setSize (BPy_Object *self, PyObject *args);
static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args);
static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args); static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args);
/*****************************************************************************/ /*****************************************************************************/
@ -159,6 +161,8 @@ hierarchy (faster)"},
"Returns the object's parent object"}, "Returns the object's parent object"},
{"getSize", (PyCFunction)Object_getSize, METH_VARARGS, {"getSize", (PyCFunction)Object_getSize, METH_VARARGS,
"Returns the object's size (x, y, z)"}, "Returns the object's size (x, y, z)"},
{"getTimeOffset", (PyCFunction)Object_getTimeOffset, METH_NOARGS,
"Returns the object's time offset"},
{"getTracked", (PyCFunction)Object_getTracked, METH_NOARGS, {"getTracked", (PyCFunction)Object_getTracked, METH_NOARGS,
"Returns the object's tracked object"}, "Returns the object's tracked object"},
{"getType", (PyCFunction)Object_getType, METH_NOARGS, {"getType", (PyCFunction)Object_getType, METH_NOARGS,
@ -208,6 +212,8 @@ objects."},
{"setSize", (PyCFunction)Object_setSize, METH_VARARGS, {"setSize", (PyCFunction)Object_setSize, METH_VARARGS,
"Set the object's size. The first argument must be a vector\n\ "Set the object's size. The first argument must be a vector\n\
triple."}, triple."},
{"setTimeOffset", (PyCFunction)Object_setTimeOffset, METH_VARARGS,
"Set the object's time offset."},
{"shareFrom", (PyCFunction)Object_shareFrom, METH_VARARGS, {"shareFrom", (PyCFunction)Object_shareFrom, METH_VARARGS,
"Link data of self with object specified in the argument. This\n\ "Link data of self with object specified in the argument. This\n\
works only if self and the object specified are of the same type."}, works only if self and the object specified are of the same type."},
@ -843,6 +849,17 @@ static PyObject *Object_getSize (BPy_Object *self, PyObject *args)
"couldn't get Object.size attributes")); "couldn't get Object.size attributes"));
} }
static PyObject *Object_getTimeOffset (BPy_Object *self)
{
PyObject *attr = Py_BuildValue ("f", self->object->sf);
if (attr) return (attr);
return (PythonReturnErrorObject (PyExc_RuntimeError,
"couldn't get Object.sf attributes"));
}
static PyObject *Object_getTracked (BPy_Object *self) static PyObject *Object_getTracked (BPy_Object *self)
{ {
PyObject *attr; PyObject *attr;
@ -1390,6 +1407,22 @@ static PyObject *Object_setSize (BPy_Object *self, PyObject *args)
return (Py_None); return (Py_None);
} }
static PyObject *Object_setTimeOffset (BPy_Object *self, PyObject *args)
{
float newTimeOffset;
if (!PyArg_ParseTuple (args, "f", &newTimeOffset))
{
return (PythonReturnErrorObject (PyExc_AttributeError,
"expected a float as argument"));
}
self->object->sf=newTimeOffset;
Py_INCREF (Py_None);
return (Py_None);
}
static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args) static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args)
{ {
BPy_Object * object; BPy_Object * object;