Index: source/blender/python/api2_2x/Curve.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Curve.c,v retrieving revision 1.22 diff -u -r1.22 Curve.c --- source/blender/python/api2_2x/Curve.c 13 Jan 2005 03:42:53 -0000 1.22 +++ source/blender/python/api2_2x/Curve.c 24 Jan 2005 15:14:07 -0000 @@ -80,6 +80,7 @@ static PyObject *Curve_setName( BPy_Curve * self, PyObject * args ); static PyObject *Curve_getPathLen( BPy_Curve * self ); static PyObject *Curve_setPathLen( BPy_Curve * self, PyObject * args ); +static PyObject *Curve_getLen( BPy_Curve * self ); static PyObject *Curve_getTotcol( BPy_Curve * self ); static PyObject *Curve_setTotcol( BPy_Curve * self, PyObject * args ); static PyObject *Curve_getMode( BPy_Curve * self ); @@ -149,7 +150,9 @@ METH_NOARGS, "() - Return Curve path length"}, {"setPathLen", ( PyCFunction ) Curve_setPathLen, METH_VARARGS, "(int) - Sets Curve path length"}, - {"getTotcol", ( PyCFunction ) Curve_getTotcol, + {"getLen", ( PyCFunction ) Curve_getLen, + METH_NOARGS, "() - Return Curve length"}, + {"getTotcol", ( PyCFunction ) Curve_getTotcol, METH_NOARGS, "() - Return the number of materials of the curve"}, {"setTotcol", ( PyCFunction ) Curve_setTotcol, METH_VARARGS, "(int) - Sets the number of materials of the curve"}, @@ -496,6 +499,20 @@ } +static PyObject *Curve_getLen( BPy_Curve * self ) +{ + if(self->curve->path) { + PyObject *attr = PyFloat_FromDouble( ( double ) self->curve->path->totdist ); + if( attr ) + return attr; + + Py_INCREF( Py_None ); + return Py_None; + } + Py_INCREF( Py_None ); + return Py_None; +} + static PyObject *Curve_getTotcol( BPy_Curve * self ) { PyObject *attr = PyInt_FromLong( ( long ) self->curve->totcol ); @@ -1353,6 +1370,8 @@ attr = PyString_FromString( self->curve->id.name + 2 ); if( strcmp( name, "pathlen" ) == 0 ) attr = PyInt_FromLong( self->curve->pathlen ); + if( strcmp( name, "len" ) == 0 ) + attr = PyFloat_FromDouble( self->curve->path->totdist ); if( strcmp( name, "totcol" ) == 0 ) attr = PyInt_FromLong( self->curve->totcol ); if( strcmp( name, "flag" ) == 0 ) Index: source/blender/python/api2_2x/doc/Curve.py =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Curve.py,v retrieving revision 1.9 diff -u -r1.9 Curve.py --- source/blender/python/api2_2x/doc/Curve.py 13 Jan 2005 03:42:53 -0000 1.9 +++ source/blender/python/api2_2x/doc/Curve.py 24 Jan 2005 15:14:07 -0000 @@ -62,6 +62,7 @@ @cvar name: The Curve Data name. @cvar pathlen: The Curve Data path length. + @cvar len: The Curve Datas length. @cvar totcol: The Curve Data maximal number of linked materials. @cvar flag: The Curve Data flag value; see function getFlag for the semantics. @cvar bevresol: The Curve Data bevel resolution. @@ -102,6 +103,13 @@ @rtype: PyNone @type len: int @param len: the new curve's length. + """ + + def getLen(): + """ + Get this Curve's length. + @rtype: float + @return: the path length. """ def getTotcol():