diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-08-15 15:24:08 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-08-15 15:24:08 +0400 |
commit | 8e7095a464a4f35186a31069c7d02c5bf8748327 (patch) | |
tree | e3680a39c822c6181165683ca1890aaef9af4fd9 /source/blender/python/api2_2x/Curve.c | |
parent | 2fc1f4ac426a1cde79d6357c9ff21c6a57533ce5 (diff) |
Added __copy__ to armature, material, curve, group
Diffstat (limited to 'source/blender/python/api2_2x/Curve.c')
-rw-r--r-- | source/blender/python/api2_2x/Curve.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c index c17bbe5789a..5fbb2ad15bc 100644 --- a/source/blender/python/api2_2x/Curve.c +++ b/source/blender/python/api2_2x/Curve.c @@ -113,6 +113,7 @@ static PyObject *Curve_setBevOb( BPy_Curve * self, PyObject * args ); static PyObject *Curve_getTaperOb( BPy_Curve * self ); static PyObject *Curve_setTaperOb( BPy_Curve * self, PyObject * args ); +static PyObject *Curve_copy( BPy_Curve * self ); static PyObject *Curve_getIter( BPy_Curve * self ); static PyObject *Curve_iterNext( BPy_Curve * self ); @@ -226,6 +227,8 @@ Sets a control point "}, "() - returns Taper Object assigned to this Curve"}, {"setTaperOb", ( PyCFunction ) Curve_setTaperOb, METH_VARARGS, "() - assign a Taper Object to this Curve"}, + {"__copy__", ( PyCFunction ) Curve_copy, METH_NOARGS, + "() - make a copy of this curve data"}, {NULL, NULL, 0, NULL} }; @@ -1385,6 +1388,40 @@ PyObject *Curve_setTaperOb( BPy_Curve * self, PyObject * args ) return EXPP_incr_ret( Py_None ); } +/*****************************************************************************/ +/* Function: Curve_copy */ +/* Description: Return a copy of this curve data. */ +/*****************************************************************************/ + +PyObject *Curve_copy( BPy_Curve * self ) +{ + BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */ + Curve *blcurve = 0; /* for actual Curve Data we create in Blender */ + + /* copies the data */ + blcurve = copy_curve( self->curve ); /* first create the Curve Data in Blender */ + + if( blcurve == NULL ) /* bail out if add_curve() failed */ + return ( EXPP_ReturnPyObjError + ( PyExc_RuntimeError, + "couldn't create Curve Data in Blender" ) ); + + /* return user count to zero because add_curve() inc'd it */ + blcurve->id.us = 0; + + /* create python wrapper obj */ + pycurve = ( BPy_Curve * ) PyObject_NEW( BPy_Curve, &Curve_Type ); + + if( pycurve == NULL ) + return ( EXPP_ReturnPyObjError + ( PyExc_MemoryError, + "couldn't create Curve Data object" ) ); + + pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */ + return ( PyObject * ) pycurve; +} + + /* * Curve_getIter * |