several bug fixes
This commit is contained in:
@@ -45,20 +45,20 @@ static PyObject *M_Curve_New(PyObject *self, PyObject *args)
|
||||
|
||||
printf ("In Curve_New()\n");
|
||||
if (!PyArg_ParseTuple(args, "|s", &name))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected string argument or no argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected string argument or no argument"));
|
||||
|
||||
blcurve = add_curve(OB_CURVE); /* first create the Curve Data in Blender */
|
||||
if (blcurve == NULL)
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create Curve Data in Blender"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create Curve Data in Blender"));
|
||||
|
||||
pycurve = (C_Curve *)PyObject_NEW(C_Curve, &Curve_Type);
|
||||
|
||||
|
||||
if (pycurve == NULL)
|
||||
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||
"couldn't create Curve Data object"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||
"couldn't create Curve Data object"));
|
||||
|
||||
pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */
|
||||
if (name)
|
||||
@@ -84,7 +84,7 @@ static PyObject *M_Curve_Get(PyObject *self, PyObject *args)
|
||||
printf ("In Curve_Get()\n");
|
||||
if (!PyArg_ParseTuple(args, "|s", &name))//expects nothing or a string
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected string argument"));
|
||||
"expected string argument"));
|
||||
if(name){//a name has been given
|
||||
/* Use the name to search for the curve requested */
|
||||
wanted_curv = NULL;
|
||||
@@ -93,8 +93,8 @@ static PyObject *M_Curve_Get(PyObject *self, PyObject *args)
|
||||
while ((curv_iter) && (wanted_curv == NULL)) {
|
||||
|
||||
if (strcmp (name, curv_iter->id.name+2) == 0) {
|
||||
wanted_curv = (C_Curve *)PyObject_NEW(C_Curve, &Curve_Type);
|
||||
if (wanted_curv) wanted_curv->curve = curv_iter;
|
||||
wanted_curv = (C_Curve *)PyObject_NEW(C_Curve, &Curve_Type);
|
||||
if (wanted_curv) wanted_curv->curve = curv_iter;
|
||||
}
|
||||
|
||||
curv_iter = curv_iter->id.next;
|
||||
@@ -109,33 +109,27 @@ static PyObject *M_Curve_Get(PyObject *self, PyObject *args)
|
||||
|
||||
|
||||
return (PyObject*)wanted_curv;
|
||||
}/*if(name)*/
|
||||
else{/*no name has been given; return a list with all curves in the scene */
|
||||
int index = 0;
|
||||
PyObject *curvlist, *pyobj;
|
||||
}//if(name)
|
||||
else{//no name has been given; return a list of all curves by name.
|
||||
PyObject *curvlist;
|
||||
|
||||
curv_iter = G.main->curve.first;
|
||||
curvlist = PyList_New (BLI_countlist (&(G.main->curve)));
|
||||
curvlist = PyList_New (0);
|
||||
|
||||
if (curvlist == NULL)
|
||||
return (PythonReturnErrorObject (PyExc_MemoryError,
|
||||
"couldn't create PyList"));
|
||||
"couldn't create PyList"));
|
||||
|
||||
while (curv_iter) {
|
||||
pyobj = CurveCreatePyObject (curv_iter);
|
||||
|
||||
if (!pyobj)
|
||||
return (PythonReturnErrorObject (PyExc_MemoryError,
|
||||
"couldn't create PyString"));
|
||||
|
||||
PyList_SET_ITEM (curvlist, index, pyobj);
|
||||
C_Curve *found_cur=(C_Curve*)PyObject_NEW(C_Curve,&Curve_Type);
|
||||
found_cur->curve = curv_iter;
|
||||
PyList_Append (curvlist, (PyObject *)found_cur);
|
||||
|
||||
curv_iter = curv_iter->id.next;
|
||||
index++;
|
||||
}
|
||||
|
||||
return (curvlist);
|
||||
}/*else*/
|
||||
}//else
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -168,7 +162,7 @@ static PyObject *Curve_getName(C_Curve *self)
|
||||
if (attr) return attr;
|
||||
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get Curve.name attribute"));
|
||||
"couldn't get Curve.name attribute"));
|
||||
}
|
||||
|
||||
static PyObject *Curve_setName(C_Curve *self, PyObject *args)
|
||||
@@ -178,7 +172,7 @@ static PyObject *Curve_setName(C_Curve *self, PyObject *args)
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &(name)))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected string argument"));
|
||||
"expected string argument"));
|
||||
PyOS_snprintf(buf, sizeof(buf), "%s", name);
|
||||
rename_id(&self->curve->id, buf); /* proper way in Blender */
|
||||
|
||||
@@ -193,7 +187,7 @@ static PyObject *Curve_getPathLen(C_Curve *self)
|
||||
if (attr) return attr;
|
||||
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get Curve.pathlen attribute"));
|
||||
"couldn't get Curve.pathlen attribute"));
|
||||
}
|
||||
|
||||
|
||||
@@ -201,8 +195,8 @@ static PyObject *Curve_setPathLen(C_Curve *self, PyObject *args)
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &(self->curve->pathlen)))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
@@ -216,7 +210,7 @@ static PyObject *Curve_getTotcol(C_Curve *self)
|
||||
if (attr) return attr;
|
||||
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get Curve.totcol attribute"));
|
||||
"couldn't get Curve.totcol attribute"));
|
||||
}
|
||||
|
||||
|
||||
@@ -224,8 +218,8 @@ static PyObject *Curve_setTotcol(C_Curve *self, PyObject *args)
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &(self->curve->totcol)))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
@@ -239,7 +233,7 @@ static PyObject *Curve_getMode(C_Curve *self)
|
||||
if (attr) return attr;
|
||||
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get Curve.flag attribute"));
|
||||
"couldn't get Curve.flag attribute"));
|
||||
}
|
||||
|
||||
|
||||
@@ -247,8 +241,8 @@ static PyObject *Curve_setMode(C_Curve *self, PyObject *args)
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &(self->curve->flag)))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
@@ -262,7 +256,7 @@ static PyObject *Curve_getBevresol(C_Curve *self)
|
||||
if (attr) return attr;
|
||||
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get Curve.bevresol attribute"));
|
||||
"couldn't get Curve.bevresol attribute"));
|
||||
}
|
||||
|
||||
|
||||
@@ -270,8 +264,8 @@ static PyObject *Curve_setBevresol(C_Curve *self, PyObject *args)
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &(self->curve->bevresol)))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
@@ -285,7 +279,7 @@ static PyObject *Curve_getResolu(C_Curve *self)
|
||||
if (attr) return attr;
|
||||
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get Curve.resolu attribute"));
|
||||
"couldn't get Curve.resolu attribute"));
|
||||
}
|
||||
|
||||
|
||||
@@ -293,8 +287,8 @@ static PyObject *Curve_setResolu(C_Curve *self, PyObject *args)
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &(self->curve->resolu)))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
@@ -309,7 +303,7 @@ static PyObject *Curve_getResolv(C_Curve *self)
|
||||
if (attr) return attr;
|
||||
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get Curve.resolv attribute"));
|
||||
"couldn't get Curve.resolv attribute"));
|
||||
}
|
||||
|
||||
|
||||
@@ -317,8 +311,8 @@ static PyObject *Curve_setResolv(C_Curve *self, PyObject *args)
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &(self->curve->resolv)))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int argument"));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
@@ -333,7 +327,7 @@ static PyObject *Curve_getWidth(C_Curve *self)
|
||||
if (attr) return attr;
|
||||
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get Curve.width attribute"));
|
||||
"couldn't get Curve.width attribute"));
|
||||
}
|
||||
|
||||
|
||||
@@ -341,8 +335,8 @@ static PyObject *Curve_setWidth(C_Curve *self, PyObject *args)
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, "f", &(self->curve->width)))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected float argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected float argument"));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
@@ -356,7 +350,7 @@ static PyObject *Curve_getExt1(C_Curve *self)
|
||||
if (attr) return attr;
|
||||
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get Curve.ext1 attribute"));
|
||||
"couldn't get Curve.ext1 attribute"));
|
||||
}
|
||||
|
||||
|
||||
@@ -364,8 +358,8 @@ static PyObject *Curve_setExt1(C_Curve *self, PyObject *args)
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, "f", &(self->curve->ext1)))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected float argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected float argument"));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
@@ -380,7 +374,7 @@ static PyObject *Curve_getExt2(C_Curve *self)
|
||||
if (attr) return attr;
|
||||
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get Curve.ext2 attribute"));
|
||||
"couldn't get Curve.ext2 attribute"));
|
||||
}
|
||||
|
||||
|
||||
@@ -388,8 +382,8 @@ static PyObject *Curve_setExt2(C_Curve *self, PyObject *args)
|
||||
{
|
||||
|
||||
if (!PyArg_ParseTuple(args, "f", &(self->curve->ext2)))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected float argument"));
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected float argument"));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
@@ -408,13 +402,13 @@ static PyObject *Curve_setControlPoint(C_Curve *self, PyObject *args)
|
||||
if (ptrnurb->bp)
|
||||
if (!PyArg_ParseTuple(args, "iiffff", &numcourbe,&numpoint,&x,&y,&z,&w))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int int float float float float arguments"));
|
||||
"expected int int float float float float arguments"));
|
||||
if (ptrnurb->bezt)
|
||||
if (!PyArg_ParseTuple(args, "iifffffffff", &numcourbe,&numpoint,
|
||||
bez,bez+1,bez+2,bez+3,bez+4,bez+5,bez+6,bez+7,bez+8))
|
||||
bez,bez+1,bez+2,bez+3,bez+4,bez+5,bez+6,bez+7,bez+8))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int int float float float float float float "
|
||||
"float float float arguments"));
|
||||
"expected int int float float float float float float "
|
||||
"float float float arguments"));
|
||||
|
||||
for(i = 0;i< numcourbe;i++)
|
||||
ptrnurb=ptrnurb->next;
|
||||
@@ -428,10 +422,10 @@ static PyObject *Curve_setControlPoint(C_Curve *self, PyObject *args)
|
||||
if (ptrnurb->bezt)
|
||||
{
|
||||
for(i = 0;i<3;i++)
|
||||
for(j = 0;j<3;j++)
|
||||
ptrnurb->bezt[numpoint].vec[i][j] = bez[i*3+j];
|
||||
for(j = 0;j<3;j++)
|
||||
ptrnurb->bezt[numpoint].vec[i][j] = bez[i*3+j];
|
||||
}
|
||||
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
@@ -445,7 +439,7 @@ static PyObject *Curve_getControlPoint(C_Curve *self, PyObject *args)
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii", &numcourbe,&numpoint))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected int int arguments"));
|
||||
"expected int int arguments"));
|
||||
//check args ???
|
||||
if (!self->curve->nurb.first)return liste;
|
||||
ptrnurb = self->curve->nurb.first;
|
||||
@@ -455,16 +449,16 @@ static PyObject *Curve_getControlPoint(C_Curve *self, PyObject *args)
|
||||
if (ptrnurb->bp)
|
||||
{
|
||||
for(i = 0;i< 4;i++)
|
||||
PyList_Append(liste, PyFloat_FromDouble( ptrnurb->bp[numpoint].vec[i]));
|
||||
PyList_Append(liste, PyFloat_FromDouble( ptrnurb->bp[numpoint].vec[i]));
|
||||
}
|
||||
|
||||
if (ptrnurb->bezt)
|
||||
{
|
||||
liste = PyList_New(9);
|
||||
for(i = 0;i< 3;i++)
|
||||
for(j = 0;j< 3;j++)
|
||||
PyList_Append(liste,
|
||||
PyFloat_FromDouble( ptrnurb->bezt[numpoint].vec[i][j]));
|
||||
for(j = 0;j< 3;j++)
|
||||
PyList_Append(liste,
|
||||
PyFloat_FromDouble( ptrnurb->bezt[numpoint].vec[i][j]));
|
||||
}
|
||||
|
||||
return liste;
|
||||
@@ -487,7 +481,7 @@ static PyObject *Curve_setLoc(C_Curve *self, PyObject *args)
|
||||
|
||||
if (!PyArg_ParseTuple(args, "fff",&x,&y,&z))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected float float float arguments"));
|
||||
"expected float float float arguments"));
|
||||
|
||||
self->curve->loc[0] = x;
|
||||
self->curve->loc[1] = y;
|
||||
@@ -513,7 +507,7 @@ static PyObject *Curve_setRot(C_Curve *self, PyObject *args)
|
||||
|
||||
if (!PyArg_ParseTuple(args, "fff",&x,&y,&z))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected float float float arguments"));
|
||||
"expected float float float arguments"));
|
||||
|
||||
self->curve->rot[0] = x;
|
||||
self->curve->rot[1] = y;
|
||||
@@ -538,7 +532,7 @@ static PyObject *Curve_setSize(C_Curve *self, PyObject *args)
|
||||
|
||||
if (!PyArg_ParseTuple(args, "fff",&x,&y,&z))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected float float float arguments"));
|
||||
"expected float float float arguments"));
|
||||
|
||||
self->curve->size[0] = x;
|
||||
self->curve->size[1] = y;
|
||||
@@ -598,7 +592,7 @@ static PyObject *CurveGetAttr (C_Curve *self, char *name)//getattr
|
||||
|
||||
if (!attr)
|
||||
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||
"couldn't create PyObject"));
|
||||
"couldn't create PyObject"));
|
||||
|
||||
if (attr != Py_None) return attr; /* member attribute found, return it */
|
||||
|
||||
@@ -664,7 +658,7 @@ static int CurvePrint(C_Curve *self, FILE *fp, int flags) //print
|
||||
{
|
||||
|
||||
fprintf(fp, "[Curve \"%s\"]\n", self->curve->id.name+2);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user