From 1a87f3a4aa7045d2f7e4c85ed2e5d0ae117c71b0 Mon Sep 17 00:00:00 2001 From: Willian Padovani Germano Date: Tue, 20 May 2003 03:53:30 +0000 Subject: [PATCH] Guignot implemented 3 functions needed by the Object Module --- source/blender/python/api2_2x/Curve.c | 36 +++++++++++++++++++++++++++ source/blender/python/api2_2x/Curve.h | 12 ++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c index a981dea4dd5..05fbd5a2d1c 100644 --- a/source/blender/python/api2_2x/Curve.c +++ b/source/blender/python/api2_2x/Curve.c @@ -605,3 +605,39 @@ static PyObject *CurveRepr (C_Curve *self) /* used by 'repr' */ return PyString_FromString(self->curve->id.name+2); } + +/*****************************************************************************/ +/* Functions: CurveCreatePyObject, CurveCheckPyObject, CurveFromPyObject */ +/* Description: These helper functions are needed by the Object module to */ +/* work with its specific object.data, Curve Data in this case. */ +/*****************************************************************************/ +PyObject* CurveCreatePyObject (struct Curve *curve) +{ + C_Curve * blen_object; + + printf ("In CurveCreatePyObject\n"); + + blen_object = (C_Curve*)PyObject_NEW (C_Curve, &Curve_Type); + + if (blen_object == NULL) + { + return (NULL); + } + blen_object->curve = curve; + return ((PyObject*)blen_object); + +} + +int CurveCheckPyObject (PyObject *py_obj) +{ + return (py_obj->ob_type == &Curve_Type); +} + +struct Curve* CurveFromPyObject (PyObject *py_obj) +{ + C_Curve * blen_obj; + + blen_obj = (C_Curve*)py_obj; + return (blen_obj->curve); + +} diff --git a/source/blender/python/api2_2x/Curve.h b/source/blender/python/api2_2x/Curve.h index 3baa538f2ab..711ce5c3692 100644 --- a/source/blender/python/api2_2x/Curve.h +++ b/source/blender/python/api2_2x/Curve.h @@ -145,11 +145,12 @@ static PyMethodDef C_Curve_methods[] = { {"getExt2", (PyCFunction)Curve_getExt2, METH_NOARGS,"() - Return ext2"}, {"setExt2", (PyCFunction)Curve_setExt2, METH_VARARGS,"(int) - Sets ext2"}, {"getControlPoint", (PyCFunction)Curve_getControlPoint, METH_VARARGS, - "(int numcurve,int numpoint) - Gets a control point.Depending upon\ - the curve type, returne a list of 4 or 9 floats"}, + "(int numcurve,int numpoint) - Gets a control point.Depending upon" + " the curve type, returne a list of 4 or 9 floats"}, {"setControlPoint", (PyCFunction)Curve_setControlPoint, METH_VARARGS, - "(int numcurve,int numpoint,float x,float y,float z, float w)(nurbs)\ - or (int numcurve,int numpoint,float x1,...,x9(bezier) Sets a control point "}, + "(int numcurve,int numpoint,float x,float y,float z, float w)(nurbs)" + " or (int numcurve,int numpoint,float x1,...,x9(bezier) " + "Sets a control point "}, {"getLoc", (PyCFunction)Curve_getLoc, METH_NOARGS,"() - Gets Location"}, {"setLoc", (PyCFunction)Curve_setLoc, METH_VARARGS, "(float x,float y,float z) - Sets Location"}, @@ -170,6 +171,9 @@ static int CurvePrint (C_Curve *msh, FILE *fp, int flags); static int CurveSetAttr (C_Curve *msh, char *name, PyObject *v); static PyObject *CurveGetAttr (C_Curve *msh, char *name); static PyObject *CurveRepr (C_Curve *msh); +PyObject* CurveCreatePyObject (struct Curve *curve); +int CurveCheckPyObject (PyObject *py_obj); +struct Curve* CurveFromPyObject (PyObject *py_obj); /*****************************************************************************/ /* Python Curve_Type structure definition: */