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/Camera.c | |
parent | b92837c7c36d1f8d890c66e3693ea1c24efd8c9c (diff) |
Added python __copy__ to Camera, Lattice, Metaball and World.
Diffstat (limited to 'source/blender/python/api2_2x/Camera.c')
-rw-r--r-- | source/blender/python/api2_2x/Camera.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c index a8625def1c9..395eb25a06f 100644 --- a/source/blender/python/api2_2x/Camera.c +++ b/source/blender/python/api2_2x/Camera.c @@ -122,6 +122,7 @@ static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args ); static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args ); static PyObject *Camera_clearScriptLinks( BPy_Camera * self, PyObject * args ); static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args ); +static PyObject *Camera_copy( BPy_Camera * self ); Camera *GetCameraByName( char *name ); @@ -184,6 +185,8 @@ static PyMethodDef BPy_Camera_methods[] = { METH_NOARGS, "() - Delete all scriptlinks from this camera.\n" "([s1<,s2,s3...>]) - Delete specified scriptlinks from this camera."}, + {"__copy__", ( PyCFunction ) Camera_copy, METH_NOARGS, + "() - Return a copy of the camera."}, {NULL, NULL, 0, NULL} }; @@ -811,6 +814,31 @@ static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args ) return NULL; } +/* cam.__copy__ */ +static PyObject *Camera_copy( BPy_Camera * self ) +{ + PyObject *pycam; /* for Camera Data object wrapper in Python */ + Camera *blcam; /* for actual Camera Data we create in Blender */ + + blcam = copy_camera( self->camera ); /* first create the Camera Data in Blender */ + + if( blcam ) /* now create the wrapper obj in Python */ + pycam = Camera_CreatePyObject( blcam ); + else + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "couldn't create Camera Data in Blender" ); + + /* let's return user count to zero, because ... */ + blcam->id.us = 0; /* ... copy_camera() incref'ed it */ + /* XXX XXX Do this in other modules, too */ + + if( pycam == NULL ) + return EXPP_ReturnPyObjError( PyExc_MemoryError, + "couldn't create Camera PyObject" ); + + return pycam; +} + static void Camera_dealloc( BPy_Camera * self ) { PyObject_DEL( self ); |