diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-08-16 18:06:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-08-16 18:06:24 +0400 |
commit | 9ef3e8092bf5185fa67ab45be5a769b04490c787 (patch) | |
tree | f28b2c48911eb82c9eb6893d5ffd26b5d8d7f9fa /source/blender/python/api2_2x/Metaball.c | |
parent | b92837c7c36d1f8d890c66e3693ea1c24efd8c9c (diff) |
Added python __copy__ to Camera, Lattice, Metaball and World.
Diffstat (limited to 'source/blender/python/api2_2x/Metaball.c')
-rw-r--r-- | source/blender/python/api2_2x/Metaball.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c index 5987cee9e7a..c4ddac7d684 100644 --- a/source/blender/python/api2_2x/Metaball.c +++ b/source/blender/python/api2_2x/Metaball.c @@ -108,6 +108,7 @@ static PyObject *Metaball_getrot( BPy_Metaball * self ); static PyObject *Metaball_setrot( BPy_Metaball * self, PyObject * args ); static PyObject *Metaball_getsize( BPy_Metaball * self ); static PyObject *Metaball_setsize( BPy_Metaball * self, PyObject * args ); +static PyObject *Metaball_copy( BPy_Metaball * self ); /*****************************************************************************/ /* Python BPy_Metaball methods table: */ @@ -180,6 +181,8 @@ static PyMethodDef BPy_Metaball_methods[] = { METH_NOARGS, "() - Gets Metaball size values"}, {"setsize", ( PyCFunction ) Metaball_setsize, METH_VARARGS, "(f f f) - Sets Metaball size values"}, + {"__copy__", ( PyCFunction ) Metaball_copy, + METH_NOARGS, "() - Return a copy of this metaball"}, {NULL, NULL, 0, NULL} }; @@ -678,6 +681,34 @@ static PyObject *Metaball_setThresh( BPy_Metaball * self, PyObject * args ) } +static PyObject *Metaball_copy( BPy_Metaball * self ) +{ + BPy_Metaball *pymball; /* for Data object wrapper in Python */ + MetaBall *blmball; /* for actual Data we create in Blender */ + + blmball = copy_mball( self->metaball ); /* first create the MetaBall Data in Blender */ + + if( blmball ) { + /* return user count to zero since add_mball() incref'ed it */ + blmball->id.us = 0; + /* now create the wrapper obj in Python */ + pymball = + ( BPy_Metaball * ) PyObject_NEW( BPy_Metaball, + &Metaball_Type ); + } else + return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, + "couldn't create MetaBall Data in Blender" ) ); + + if( pymball == NULL ) + return ( EXPP_ReturnPyObjError( PyExc_MemoryError, + "couldn't create MetaBall Data object" ) ); + + pymball->metaball = blmball; + + return ( PyObject * ) pymball; +} + + /**************************************************************************/ /* get/set metaelems data, */ /***************************************************************************/ |