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/Material.c | |
parent | 2fc1f4ac426a1cde79d6357c9ff21c6a57533ce5 (diff) |
Added __copy__ to armature, material, curve, group
Diffstat (limited to 'source/blender/python/api2_2x/Material.c')
-rw-r--r-- | source/blender/python/api2_2x/Material.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c index 600d5f71440..6a9670f90f7 100644 --- a/source/blender/python/api2_2x/Material.c +++ b/source/blender/python/api2_2x/Material.c @@ -597,6 +597,7 @@ static PyObject *Material_addScriptLink(BPy_Material * self, PyObject * args ); static PyObject *Material_clearScriptLinks(BPy_Material *self, PyObject *args); static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args ); +static PyObject *Material_copy( BPy_Material * self ); /*****************************************************************************/ @@ -820,6 +821,8 @@ static PyMethodDef BPy_Material_methods[] = { {"clearScriptLinks", ( PyCFunction ) Material_clearScriptLinks, METH_VARARGS, "() - Delete all scriptlinks from this material.\n" "([s1<,s2,s3...>]) - Delete specified scriptlinks from this material."}, + {"__copy__", ( PyCFunction ) Material_copy, METH_NOARGS, + "() - Return a copy of the material."}, {NULL, NULL, 0, NULL} }; @@ -2473,6 +2476,29 @@ static PyObject *Material_getScriptLinks( BPy_Material * self, return NULL; } +/* mat.__copy__ */ +static PyObject *Material_copy( BPy_Material * self ) +{ + BPy_Material *pymat; /* for Material Data object wrapper in Python */ + Material *blmat; /* for actual Material Data we create in Blender */ + + blmat = copy_material( self->material ); /* first copy the Material Data in Blender */ + + if( blmat ) /* now create the wrapper obj in Python */ + pymat = ( BPy_Material * ) Material_CreatePyObject( blmat ); + else + return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, + "couldn't create Material Data in Blender" ) ); + + blmat->id.us = 0; /* was incref'ed by add_material() above */ + + if( pymat == NULL ) + return ( EXPP_ReturnPyObjError( PyExc_MemoryError, + "couldn't create Material Data object" ) ); + + return ( PyObject * ) pymat; +} + /*****************************************************************************/ /* Function: Material_repr */ /* Description: This is a callback function for the BPy_Material type. It */ |