made attributes (name, property, users, fakeUser, lib) into functions all python types can use.

removed a lot of code duplication when moving to this.
Also removed unused functions GetMaterialByName(), same for Mesh, Object, World etc.
This commit is contained in:
2007-02-25 07:36:50 +00:00
parent e64b887fad
commit 436e1697fd
24 changed files with 209 additions and 1423 deletions

View File

@@ -610,28 +610,6 @@ AttributeError:
"expected a list of integers" );
}
//------------------------Armature.users (getter)
static PyObject *Armature_getUsers( BPy_Armature * self )
{
return PyInt_FromLong( self->armature->id.us );
}
//------------------------Armature.fakeUser (getter)
static PyObject *Armature_getFakeUser( BPy_Armature * self )
{
if (self->armature->id.flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
//------------------------Armature.fakeUser (setter)
static int Armature_setFakeUser( BPy_Armature * self, PyObject * value )
{
return SetIdFakeUser(&self->armature->id, value);
}
//------------------------Armature.mirrorEdit (getter)
static PyObject *Armature_getMirrorEdit(BPy_Armature *self, void *closure)
{
@@ -935,38 +913,6 @@ AttributeError:
return EXPP_intError(PyExc_AttributeError, "%s%s",
sArmatureBadArgs, "Expects True or False");
}
//------------------------Armature.name (getter)
//Gets the name of the armature
static PyObject *Armature_getName(BPy_Armature *self, void *closure)
{
return PyString_FromString(self->armature->id.name +2); //*new*
}
//------------------------Armature.name (setter)
//Sets the name of the armature
static int Armature_setName(BPy_Armature *self, PyObject *value, void *closure)
{
char *name;
if(value){
if(PyString_Check(value)){
name = PyString_AsString(value);
rename_id(&self->armature->id, name);
return 0;
}
}
goto AttributeError;
AttributeError:
return EXPP_intError(PyExc_AttributeError, "%s%s",
sArmatureBadArgs, "Expects string");
}
//------------------------Armature.name (getter)
//Gets the name of the armature
static PyObject *Armature_getLib(BPy_Armature *self, void *closure)
{
return EXPP_GetIdLib((ID *)self->armature);
}
//------------------------Armature.bones (getter)
//Gets the name of the armature
@@ -1004,10 +950,7 @@ static PyMethodDef BPy_Armature_methods[] = {
//------------------------tp_getset
//This contains methods for attributes that require checking
static PyGetSetDef BPy_Armature_getset[] = {
{"name", (getter)Armature_getName, (setter)Armature_setName,
"The armature's name", NULL},
{"lib", (getter)Armature_getLib, (setter)NULL,
"The armature's library or None", NULL},
GENERIC_LIB_GETSETATTR,
{"bones", (getter)Armature_getBoneDict, (setter)Armature_setBoneDict,
"The armature's Bone dictionary", NULL},
{"vertexGroups", (getter)Armature_getVertexGroups, (setter)Armature_setVertexGroups,
@@ -1034,10 +977,6 @@ static PyGetSetDef BPy_Armature_getset[] = {
"Adds temporal IK chains while grabbing bones", NULL},
{"layers", (getter)Armature_getLayers, (setter)Armature_setLayers,
"List of layers for the armature", NULL},
{"users", (getter)Armature_getUsers, (setter)NULL,
"The number of object users", NULL},
{"fakeUser", (getter)Armature_getFakeUser, (setter)Armature_setFakeUser,
"The fake user status of this object", NULL},
{NULL, NULL, NULL, NULL, NULL}
};
//------------------------tp_new

View File

@@ -94,7 +94,7 @@ struct ID; /*keep me up here */
#include "Types.h"
#include "Main.h"
//for the removefakeuser hack
/*for the removefakeuser hack*/
#include "NLA.h" /*This must come first*/
#include "BKE_action.h"
@@ -850,7 +850,7 @@ static PyObject * Blender_UpdateMenus( PyObject * self )
static PyObject *Blender_RemoveFakeuser(PyObject *self, PyObject *args)
{
ID *id;
BPy_Action *py_thing; //lousy coder antont did not know how to accept any bpy thing with ID..
BPy_Action *py_thing; /*lousy coder antont did not know how to accept any bpy thing with ID..*/
if( !PyArg_ParseTuple( args, "O!", &Action_Type, &py_thing ) )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
@@ -940,9 +940,9 @@ void M_Blender_Init(void)
blender -P somescript.py -b
The if below solves the segfaults that happen when python runs and
G.scene is NULL */
if(G.background && G.main->scene.first==0) {
if(G.background && G.main->scene.first==NULL) {
Scene *sce= add_scene("1");
//set_scene(sce); /* causes a crash */
/*set_scene(sce);*/ /* causes a crash */
G.scene= sce;
}
@@ -951,7 +951,7 @@ void M_Blender_Init(void)
types_InitAll(); /* set all our pytypes to &PyType_Type */
// constants for packed files
/* constants for packed files*/
UnpackModes = Blender_UnpackModesDict( );
if( UnpackModes )
PyModule_AddObject( module, "UnpackModes", UnpackModes );

View File

@@ -110,7 +110,6 @@ struct PyMethodDef M_Camera_methods[] = {
/* Python BPy_Camera methods declarations: */
/*****************************************************************************/
static PyObject *Camera_oldgetIpo( BPy_Camera * self );
static PyObject *Camera_oldgetName( BPy_Camera * self );
static PyObject *Camera_oldgetType( BPy_Camera * self );
static PyObject *Camera_oldgetMode( BPy_Camera * self );
static PyObject *Camera_oldgetLens( BPy_Camera * self );
@@ -119,7 +118,6 @@ static PyObject *Camera_oldgetClipEnd( BPy_Camera * self );
static PyObject *Camera_oldgetDrawSize( BPy_Camera * self );
static PyObject *Camera_oldgetScale( BPy_Camera * self );
static PyObject *Camera_oldsetIpo( BPy_Camera * self, PyObject * args );
static PyObject *Camera_oldsetName( BPy_Camera * self, PyObject * args );
static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * args );
static PyObject *Camera_oldsetMode( BPy_Camera * self, PyObject * args );
static PyObject *Camera_oldsetLens( BPy_Camera * self, PyObject * args );
@@ -134,8 +132,6 @@ 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 );
/*****************************************************************************/
/* Python BPy_Camera methods table: */
@@ -144,7 +140,7 @@ static PyMethodDef BPy_Camera_methods[] = {
/* name, method, flags, doc */
{"getIpo", ( PyCFunction ) Camera_oldgetIpo, METH_NOARGS,
"() - Return Camera Data Ipo"},
{"getName", ( PyCFunction ) Camera_oldgetName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"() - Return Camera Data name"},
{"getType", ( PyCFunction ) Camera_oldgetType, METH_NOARGS,
"() - Return Camera type - 'persp':0, 'ortho':1"},
@@ -167,7 +163,7 @@ static PyMethodDef BPy_Camera_methods[] = {
"() - Unlink Ipo from this Camera."},
{"insertIpoKey", ( PyCFunction ) Camera_insertIpoKey, METH_VARARGS,
"( Camera IPO type ) - Inserts a key into IPO"},
{"setName", ( PyCFunction ) Camera_oldsetName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"(s) - Set Camera Data name"},
{"setType", ( PyCFunction ) Camera_oldsetType, METH_VARARGS,
"(s) - Set Camera type, which can be 'persp' or 'ortho'"},
@@ -209,54 +205,6 @@ static int Camera_compare( BPy_Camera * a, BPy_Camera * b );
//static PyObject *Camera_getAttr( BPy_Camera * self, char *name );
static PyObject *Camera_repr( BPy_Camera * self );
//~ /*****************************************************************************/
//~ /* Python Camera_Type structure definition: */
//~ /*****************************************************************************/
//~ PyTypeObject Camera_Type = {
//~ PyObject_HEAD_INIT( NULL ) /* required macro */
//~ NULL, /* ob_size */
//~ "Blender Camera", /* tp_name */
//~ sizeof( BPy_Camera ), /* tp_basicsize */
//~ NULL, /* tp_itemsize */
//~ /* methods */
//~ ( destructor ) Camera_dealloc, /* tp_dealloc */
//~ NULL, /* tp_print */
//~ NULL, /* tp_getattr */
//~ NULL, /* tp_setattr */
//~ ( cmpfunc ) Camera_compare, /* tp_compare */
//~ ( reprfunc ) Camera_repr, /* tp_repr */
//~ NULL, /* tp_as_number */
//~ NULL, /* tp_as_sequence */
//~ NULL, /* tp_as_mapping */
//~ NULL, /* tp_as_hash */
//~ 0, 0, 0, 0, 0, 0,
//~ 0, /* tp_doc */
//~ 0, 0, 0, 0, 0, 0,
//~ BPy_Camera_methods, /* tp_methods */
//~ 0, /* tp_members */
//~ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
//~ };
static PyObject *M_Camera_New( PyObject * self, PyObject * args,
PyObject * kwords )
{
@@ -392,25 +340,6 @@ PyObject *Camera_Init( void )
return submodule;
}
/* Three Python Camera_Type helper functions needed by the Object module: */
PyObject *Camera_CreatePyObject( Camera * cam )
@@ -424,7 +353,6 @@ PyObject *Camera_CreatePyObject( Camera * cam )
"couldn't create BPy_Camera PyObject" );
pycam->camera = cam;
return ( PyObject * ) pycam;
}
@@ -438,30 +366,6 @@ Camera *Camera_FromPyObject( PyObject * pyobj )
return ( ( BPy_Camera * ) pyobj )->camera;
}
/*****************************************************************************/
/* Description: Returns the object with the name specified by the argument */
/* name. Note that the calling function has to remove the first */
/* two characters of the object name. These two characters */
/* specify the type of the object (OB, ME, WO, ...) */
/* The function will return NULL when no object with the given */
/* name is found. */
/*****************************************************************************/
Camera *GetCameraByName( char *name )
{
Camera *cam_iter;
cam_iter = G.main->camera.first;
while( cam_iter ) {
if( StringEqual( name, GetIdName( &( cam_iter->id ) ) ) ) {
return ( cam_iter );
}
cam_iter = cam_iter->id.next;
}
/* There is no camera with the given name */
return ( NULL );
}
/*****************************************************************************/
/* Python BPy_Camera methods: */
/*****************************************************************************/
@@ -476,19 +380,6 @@ static PyObject *Camera_oldgetIpo( BPy_Camera * self )
return Ipo_CreatePyObject( ipo );
}
static PyObject *Camera_oldgetName( BPy_Camera * self )
{
PyObject *attr = PyString_FromString( self->camera->id.name + 2 );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Camera.name attribute" );
}
static PyObject *Camera_oldgetType( BPy_Camera * self )
{
PyObject *attr = PyInt_FromLong( self->camera->type );
@@ -619,19 +510,6 @@ static PyObject *Camera_oldclearIpo( BPy_Camera * self )
return EXPP_incr_ret_False(); /* no ipo found */
}
static PyObject *Camera_oldsetName( BPy_Camera * self, PyObject * args )
{
char *name;
if( !PyArg_ParseTuple( args, "s", &name ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
rename_id( &self->camera->id, name );
Py_RETURN_NONE;
}
static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * args )
{
char *type;
@@ -830,48 +708,6 @@ static void Camera_dealloc( BPy_Camera * self )
PyObject_DEL( self );
}
static PyObject *Camera_getName( BPy_Camera * self )
{
return PyString_FromString( self->camera->id.name + 2 );
}
static int Camera_setName( BPy_Camera * self, PyObject * value )
{
char *name = NULL;
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
rename_id( &self->camera->id, name);
return 0;
}
static PyObject *Camera_getLib( BPy_Camera * self )
{
return EXPP_GetIdLib((ID *)self->camera);
}
static PyObject *Camera_getUsers( BPy_Camera * self )
{
return PyInt_FromLong( self->camera->id.us );
}
static PyObject *Camera_getFakeUser( BPy_Camera * self )
{
if (self->camera->id.flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Camera_setFakeUser( BPy_Camera * self, PyObject * value )
{
return SetIdFakeUser(&self->camera->id, value);
}
static PyObject *Camera_getType( BPy_Camera * self )
{
@@ -1099,8 +935,6 @@ static PyObject *getFlagAttr( BPy_Camera *self, void *type )
Py_RETURN_FALSE;
}
/*
* set floating point attributes which require clamping
*/
@@ -1119,22 +953,7 @@ static int setFlagAttr( BPy_Camera *self, PyObject *value, void *type )
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Camera_getseters[] = {
{"name",
(getter)Camera_getName, (setter)Camera_setName,
"Camera name",
NULL},
{"lib",
(getter)Camera_getLib, (setter)NULL,
"Camera libname",
NULL},
{"users",
(getter)Camera_getUsers, (setter)NULL,
"Number of camera users",
NULL},
{"fakeUser",
(getter)Camera_getFakeUser, (setter)Camera_setFakeUser,
"Cameras fake user state",
NULL},
GENERIC_LIB_GETSETATTR,
{"type",
(getter)Camera_getType, (setter)Camera_setType,
"camera type \"persp\" or \"ortho\"",

View File

@@ -174,23 +174,10 @@ PyObject *M_Font_Load( PyObject * self, PyObject * args )
return ( PyObject * ) py_font;
}
/*--------------- Python BPy_Font methods---------------------------*/
/*--------------- Python BPy_Font getsetattr funcs ---------------------*/
/*--------------- BPy_Font.getName()--------------------------------*/
static PyObject *Font_getName( BPy_Font * self )
{
PyObject *attr = NULL;
if( self->font )
attr = PyString_FromString( self->font->id.name+2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Font.name attribute" ) );
}
/*--------------- BPy_Font.getFilename()--------------------------------*/
/*--------------- BPy_Font.filename-------------------------------------*/
static PyObject *Font_getFilename( BPy_Font * self )
{
PyObject *attr = NULL;
@@ -204,26 +191,6 @@ static PyObject *Font_getFilename( BPy_Font * self )
"couldn't get Font.filename attribute" ) );
}
static int Font_setName( BPy_Font * self, PyObject * value )
{
char *name = NULL;
if( !(self->font) )
return EXPP_ReturnIntError( PyExc_RuntimeError,
"Blender Font was deleted!" );
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
rename_id( &self->font->id, name );
return 0;
}
static int Font_setFilename( BPy_Font * self, PyObject * value )
{
char *name = NULL;
@@ -241,12 +208,6 @@ static int Font_setFilename( BPy_Font * self, PyObject * value )
return 0;
}
static PyObject *Font_getLib( BPy_Font * self )
{
return EXPP_GetIdLib((ID *)self->font);
}
/*--------------- BPy_Font.pack()---------------------------------*/
static PyObject *Font_pack( BPy_Font * self )
{
@@ -283,27 +244,11 @@ static PyObject *Font_getPacked( BPy_Font * self )
return EXPP_incr_ret_False();
}
static PyObject *Font_getUsers( BPy_Font* self )
{
return PyInt_FromLong( self->font->id.us );
}
/*****************************************************************************/
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Font_getseters[] = {
{"name",
(getter)Font_getName, (setter)Font_setName,
"Font name",
NULL},
{"lib",
(getter)Font_getLib, (setter)NULL,
"Font linked library",
NULL},
{"users",
(getter)Font_getUsers, (setter)NULL,
"Number of font users",
NULL},
GENERIC_LIB_GETSETATTR,
{"filename",
(getter)Font_getFilename, (setter)Font_setFilename,
"Font filepath",

View File

@@ -212,75 +212,7 @@ static PyObject *Group_repr( BPy_Group * obj );
static int Group_compare( BPy_Group * a, BPy_Group * b );
/*****************************************************************************/
/* Python BPy_Group methods: */
/*****************************************************************************/
static PyObject *Group_getName( BPy_Group * self )
{
PyObject *attr;
GROUP_DEL_CHECK_PY(self);
attr = PyString_FromString( self->group->id.name + 2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Group.name attribute" ) );
}
static int Group_setName( BPy_Group * self, PyObject * value )
{
char *name = NULL;
GROUP_DEL_CHECK_INT(self);
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
rename_id( &self->group->id, name );
return 0;
}
static PyObject *Group_getLib( BPy_Group * self )
{
GROUP_DEL_CHECK_PY(self);
return EXPP_GetIdLib((ID *)self->group);
}
static PyObject *Group_getUsers( BPy_Group * self )
{
GROUP_DEL_CHECK_PY(self);
return PyInt_FromLong( self->group->id.us );
}
static PyObject *Group_getFakeUser( BPy_Group * self )
{
GROUP_DEL_CHECK_PY(self);
if (self->group->id.flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Group_setFakeUser( BPy_Group * self, PyObject * value )
{
GROUP_DEL_CHECK_INT(self);
return SetIdFakeUser(&self->group->id, value);
}
static PyObject *Group_getProperties( BPy_Group * self )
{
/*sanity check, we set parent property type to Group here*/
return BPy_Wrap_IDProperty( (ID*)self->group, IDP_GetProperties((ID*)self->group, 1), NULL );
}
/*****************************************************************************/
/* Python BPy_Group methods: */
/* Python BPy_Group getsetattr funcs: */
/*****************************************************************************/
static int Group_setLayers( BPy_Group * self, PyObject * value )
{
@@ -313,28 +245,10 @@ static PyObject *Group_getLayers( BPy_Group * self )
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Group_getseters[] = {
{"name",
(getter)Group_getName, (setter)Group_setName,
"Group name",
NULL},
{"lib",
(getter)Group_getLib, (setter)NULL,
"Group linked library",
NULL},
{"users",
(getter)Group_getUsers, (setter)NULL,
"Number of group users",
NULL},
{"fakeUser",
(getter)Group_getFakeUser, (setter)Group_setFakeUser,
"Groups fake user state",
NULL},
{"properties",
(getter)Group_getProperties, NULL,
"get the ID properties associated with this group"},
GENERIC_LIB_GETSETATTR,
{"layers",
(getter)Group_getLayers, (setter)Group_setLayers,
"Number of group users",
"layer mask for this group",
NULL},
{"objects",
(getter)Group_getObjects, (setter)Group_setObjects,
@@ -629,30 +543,6 @@ Group *Group_FromPyObject( PyObject * py_grp )
return ( blen_grp->group );
}
/*****************************************************************************/
/* Description: Returns the object with the name specified by the argument */
/* name. Note that the calling function has to remove the first */
/* two characters of the object name. These two characters */
/* specify the type of the object (OB, ME, WO, ...) */
/* The function will return NULL when no object with the given */
/* name is found. */
/*****************************************************************************/
Group *GetGroupByName( char *name )
{
Group *grp_iter;
grp_iter = G.main->group.first;
while( grp_iter ) {
if( StringEqual( name, GetIdName( &( grp_iter->id ) ) ) ) {
return ( grp_iter );
}
grp_iter = grp_iter->id.next;
}
/* There is no object with the given name */
return ( NULL );
}
/*****************************************************************************/
/* Function: Group_dealloc */
/* Description: This is a callback function for the BlenObject type. It is */

View File

@@ -63,6 +63,5 @@ PyObject *Group_Init( void );
PyObject *Group_CreatePyObject( struct Group *group );
Group *Group_FromPyObject( PyObject * py_obj );
int Group_CheckPyObject( PyObject * py_obj );
Group *GetGroupByName( char *name );
#endif /* EXPP_GROUP_H */

View File

@@ -78,7 +78,6 @@ static PyObject *M_Image_Load( PyObject * self, PyObject * args );
/*****************************************************************************/
/* Python BPy_Image methods declarations: */
/*****************************************************************************/
static PyObject *Image_getName( BPy_Image * self );
static PyObject *Image_getFilename( BPy_Image * self );
static PyObject *Image_getSize( BPy_Image * self );
static PyObject *Image_getDepth( BPy_Image * self );
@@ -88,7 +87,6 @@ static PyObject *Image_getBindCode( BPy_Image * self );
static PyObject *Image_getStart( BPy_Image * self );
static PyObject *Image_getEnd( BPy_Image * self );
static PyObject *Image_getSpeed( BPy_Image * self );
static PyObject *Image_setName( BPy_Image * self, PyObject * args );
static PyObject *Image_setFilename( BPy_Image * self, PyObject * args );
static PyObject *Image_setXRep( BPy_Image * self, PyObject * args );
static PyObject *Image_setYRep( BPy_Image * self, PyObject * args );
@@ -127,7 +125,7 @@ static PyMethodDef BPy_Image_methods[] = {
"() - Get maximum x & y coordinates of current image as [x, y]"},
{"getMinXY", ( PyCFunction ) Image_getMinXY, METH_NOARGS,
"() - Get minimun x & y coordinates of image as [x, y]"},
{"getName", ( PyCFunction ) Image_getName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"() - Return Image object name"},
{"getFilename", ( PyCFunction ) Image_getFilename, METH_NOARGS,
"() - Return Image object filename"},
@@ -155,7 +153,7 @@ static PyMethodDef BPy_Image_methods[] = {
{"glFree", ( PyCFunction ) Image_glFree, METH_NOARGS,
"() - Free the image data from OpenGL texture memory only,\n\
see also image.glLoad()."},
{"setName", ( PyCFunction ) Image_setName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"(str) - Change Image object name"},
{"setFilename", ( PyCFunction ) Image_setFilename, METH_VARARGS,
"(str) - Change Image file name"},
@@ -679,6 +677,8 @@ static PyObject *Image_pack( BPy_Image * self )
static PyObject *Image_makeCurrent( BPy_Image * self )
{
printf("deprecated! use Blender.Main.images.active = image instead\n");
if (!G.sima)
Py_RETURN_FALSE;
@@ -800,20 +800,6 @@ Image *Image_FromPyObject( PyObject * pyobj )
return ( ( BPy_Image * ) pyobj )->image;
}
/*****************************************************************************/
/* Python BPy_Image methods: */
/*****************************************************************************/
static PyObject *Image_getName( BPy_Image * self )
{
PyObject *attr = PyString_FromString( self->image->id.name + 2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Image.name attribute" ) );
}
static PyObject *Image_getFilename( BPy_Image * self )
{
PyObject *attr = PyString_FromString( self->image->name );
@@ -986,19 +972,6 @@ static PyObject *Image_glLoad( BPy_Image * self )
return PyLong_FromUnsignedLong( image->bindcode );
}
static PyObject *Image_setName( BPy_Image * self, PyObject * args )
{
char *name;
if( !PyArg_ParseTuple( args, "s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" ) );
rename_id( &self->image->id, name );
Py_RETURN_NONE;
}
static PyObject *Image_setFilename( BPy_Image * self, PyObject * args )
{
char *name;
@@ -1208,7 +1181,7 @@ static int Image_setAttr( BPy_Image * self, char *name, PyObject * value )
"ImageSetAttr: couldn't create PyTuple" );
if( strcmp( name, "name" ) == 0 )
error = Image_setName( self, valtuple );
error = GenericLib_setName_with_method( self, valtuple );
else if( strcmp( name, "filename" ) == 0 )
error = Image_setFilename( self, valtuple );
else if( strcmp( name, "xrep" ) == 0 )

View File

@@ -91,9 +91,6 @@ struct PyMethodDef M_Ipo_methods[] = {
/*****************************************************************************/
/* Python BPy_Ipo methods declarations: */
/*****************************************************************************/
static PyObject *Ipo_getName( BPy_Ipo * self );
static PyObject *Ipo_oldsetName( BPy_Ipo * self, PyObject * args );
static int Ipo_setName( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_getBlocktype( BPy_Ipo * self );
static PyObject *Ipo_oldsetBlocktype( BPy_Ipo * self, PyObject * args );
static int Ipo_setBlocktype( BPy_Ipo * self, PyObject * args );
@@ -101,8 +98,6 @@ static PyObject *Ipo_getRctf( BPy_Ipo * self );
static PyObject *Ipo_oldsetRctf( BPy_Ipo * self, PyObject * args );
static int Ipo_setRctf( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_getLib( BPy_Ipo * self );
static PyObject *Ipo_getUsers( BPy_Ipo * self );
static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_getCurves( BPy_Ipo * self );
static PyObject *Ipo_getCurveNames( BPy_Ipo * self );
@@ -121,9 +116,6 @@ static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_getChannel( BPy_Ipo * self );
static int Ipo_setChannel( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_getFakeUser( BPy_Ipo * self );
static int Ipo_setFakeUser( BPy_Ipo * self, PyObject * value );
static int Ipo_length( BPy_Ipo * inst );
static PyObject *Ipo_getIpoCurveByName( BPy_Ipo * self, PyObject * key );
static int Ipo_setIpoCurveByName( BPy_Ipo * self, PyObject * key,
@@ -135,9 +127,9 @@ static int Ipo_contains( BPy_Ipo * self, PyObject * key );
/*****************************************************************************/
static PyMethodDef BPy_Ipo_methods[] = {
/* name, method, flags, doc */
{"getName", ( PyCFunction ) Ipo_getName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"() - Return Ipo Data name"},
{"setName", ( PyCFunction ) Ipo_oldsetName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"(str) - Change Ipo Data name"},
{"getBlocktype", ( PyCFunction ) Ipo_getBlocktype, METH_NOARGS,
"() - Return Ipo blocktype"},
@@ -178,22 +170,7 @@ static PyMethodDef BPy_Ipo_methods[] = {
/* Python BPy_Ipo attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Ipo_getseters[] = {
{"name",
(getter)Ipo_getName, (setter)Ipo_setName,
"Ipo data name",
NULL},
{"lib",
(getter)Ipo_getLib, (setter)NULL,
"Ipos linked library",
NULL},
{"users",
(getter)Ipo_getUsers, (setter)NULL,
"Number of Ipo users",
NULL},
{"fakeUser",
(getter)Ipo_getFakeUser, (setter)Ipo_setFakeUser,
"Ipos fake user state",
NULL},
GENERIC_LIB_GETSETATTR,
{"curves",
(getter)Ipo_getCurves, (setter)NULL,
"Ipo curves",
@@ -821,59 +798,6 @@ static PyObject *M_Ipo_Recalc( PyObject * self_unused, PyObject * args )
/*****************************************************************************/
/* Python BPy_Ipo methods: */
/*****************************************************************************/
static PyObject *Ipo_getName( BPy_Ipo * self )
{
PyObject *attr = PyString_FromString( self->ipo->id.name + 2 );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Ipo.name attribute" );
}
static int Ipo_setName( BPy_Ipo * self, PyObject * args )
{
char *name;
name = PyString_AsString( args );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
rename_id( &self->ipo->id, name );
return 0;
}
static PyObject *Ipo_getLib( BPy_Ipo * self )
{
return EXPP_GetIdLib((ID *)self->ipo);
}
static PyObject *Ipo_getUsers( BPy_Ipo * self )
{
return PyInt_FromLong( self->ipo->id.us );
}
static PyObject *Ipo_getFakeUser( BPy_Ipo * self )
{
if (self->ipo->id.flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Ipo_setFakeUser( BPy_Ipo * self, PyObject * value )
{
return SetIdFakeUser(&self->ipo->id, value);
}
static PyObject *Ipo_getBlocktype( BPy_Ipo * self )
{
PyObject *attr = PyInt_FromLong( self->ipo->blocktype );
@@ -1911,12 +1835,6 @@ static PyObject *Ipo_oldsetRctf( BPy_Ipo * self, PyObject * args )
(setter)Ipo_setRctf );
}
static PyObject *Ipo_oldsetName( BPy_Ipo * self, PyObject * args )
{
return EXPP_setterWrapperTuple( (void *)self, args,
(setter)Ipo_setName );
}
static PyObject *Ipo_oldsetBlocktype( BPy_Ipo * self, PyObject * args )
{
return EXPP_setterWrapperTuple( (void *)self, args,

View File

@@ -178,9 +178,6 @@ struct PyMethodDef M_Lamp_methods[] = {
/*****************************************************************************/
/* Python BPy_Lamp methods declarations: */
/*****************************************************************************/
static PyObject *Lamp_getName( BPy_Lamp * self );
static PyObject *Lamp_getLib( BPy_Lamp * self );
static PyObject *Lamp_getFakeUser( BPy_Lamp * self );
static PyObject *Lamp_getType( BPy_Lamp * self );
static PyObject *Lamp_getTypesConst( void );
static PyObject *Lamp_getMode( BPy_Lamp * self );
@@ -206,11 +203,9 @@ static PyObject *Lamp_getQuad2( BPy_Lamp * self );
static PyObject *Lamp_getCol( BPy_Lamp * self );
static PyObject *Lamp_getIpo( BPy_Lamp * self );
static PyObject *Lamp_getComponent( BPy_Lamp * self, void * closure );
static PyObject *Lamp_getUsers( BPy_Lamp * self );
static PyObject *Lamp_clearIpo( BPy_Lamp * self );
static PyObject *Lamp_insertIpoKey( BPy_Lamp * self, PyObject * args );
static PyObject *Lamp_oldsetIpo( BPy_Lamp * self, PyObject * args );
static PyObject *Lamp_oldsetName( BPy_Lamp * self, PyObject * args );
static PyObject *Lamp_oldsetType( BPy_Lamp * self, PyObject * args );
static PyObject *Lamp_oldsetMode( BPy_Lamp * self, PyObject * args );
static PyObject *Lamp_oldsetSamples( BPy_Lamp * self, PyObject * args );
@@ -233,8 +228,6 @@ static PyObject *Lamp_oldsetQuad1( BPy_Lamp * self, PyObject * args );
static PyObject *Lamp_oldsetQuad2( BPy_Lamp * self, PyObject * args );
static PyObject *Lamp_oldsetCol( BPy_Lamp * self, PyObject * args );
static int Lamp_setIpo( BPy_Lamp * self, PyObject * args );
static int Lamp_setName( BPy_Lamp * self, PyObject * args );
static int Lamp_setFakeUser( BPy_Lamp * self, PyObject * args );
static int Lamp_setType( BPy_Lamp * self, PyObject * args );
static int Lamp_setMode( BPy_Lamp * self, PyObject * args );
static int Lamp_setSamples( BPy_Lamp * self, PyObject * args );
@@ -266,8 +259,7 @@ static int Lamp_setComponent( BPy_Lamp * self, PyObject * value, void * closure
/*****************************************************************************/
static PyMethodDef BPy_Lamp_methods[] = {
/* name, method, flags, doc */
{"getName", ( PyCFunction ) Lamp_getName, METH_NOARGS,
"() - return Lamp name"},
{"getType", ( PyCFunction ) Lamp_getType, METH_NOARGS,
"() - return Lamp type - 'Lamp':0, 'Sun':1, 'Spot':2, 'Hemi':3, 'Area':4, 'Photon':5"},
{"getMode", ( PyCFunction ) Lamp_getMode, METH_NOARGS,
@@ -310,7 +302,7 @@ static PyMethodDef BPy_Lamp_methods[] = {
"() - return light intensity value #2 for a Quad Lamp"},
{"getCol", ( PyCFunction ) Lamp_getCol, METH_NOARGS,
"() - return light rgb color triplet"},
{"setName", ( PyCFunction ) Lamp_oldsetName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"(str) - rename Lamp"},
{"setType", ( PyCFunction ) Lamp_oldsetType, METH_VARARGS,
"(str) - change Lamp type, which can be 'Lamp', 'Sun', 'Spot', 'Hemi', 'Area', 'Photon'"},
@@ -382,22 +374,7 @@ static PyMethodDef BPy_Lamp_methods[] = {
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Lamp_getseters[] = {
{"name",
(getter)Lamp_getName, (setter)Lamp_setName,
"Lamp data name",
NULL},
{"lib",
(getter)Lamp_getLib, (setter)NULL,
"Lamps linked library",
NULL},
{"users",
(getter)Lamp_getUsers, (setter)NULL,
"Number of lamp users",
NULL},
{"fakeUser",
(getter)Lamp_getFakeUser, (setter)Lamp_setFakeUser,
"Lamps fake user state",
NULL},
GENERIC_LIB_GETSETATTR,
{"bias",
(getter)Lamp_getBias, (setter)Lamp_setBias,
"Lamp shadow map sampling bias",
@@ -879,57 +856,9 @@ Lamp *Lamp_FromPyObject( PyObject * pyobj )
return ( ( BPy_Lamp * ) pyobj )->lamp;
}
/*****************************************************************************/
/* Description: Returns the lamp with the name specified by the argument */
/* name. Note that the calling function has to remove the first */
/* two characters of the lamp name. These two characters */
/* specify the type of the object (OB, ME, WO, ...) */
/* The function will return NULL when no lamp with the given */
/* name is found. */
/*****************************************************************************/
Lamp *GetLampByName( char *name )
{
Lamp *lamp_iter;
lamp_iter = G.main->lamp.first;
while( lamp_iter ) {
if( StringEqual( name, GetIdName( &( lamp_iter->id ) ) ) ) {
return lamp_iter;
}
lamp_iter = lamp_iter->id.next;
}
/* There is no lamp with the given name */
return NULL;
}
/*****************************************************************************/
/* Python BPy_Lamp methods: */
/*****************************************************************************/
static PyObject *Lamp_getName( BPy_Lamp * self )
{
PyObject *attr = PyString_FromString( self->lamp->id.name + 2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Lamp.name attribute" ) );
}
static PyObject *Lamp_getLib( BPy_Lamp * self )
{
return EXPP_GetIdLib((ID *)self->lamp);
}
static PyObject *Lamp_getFakeUser( BPy_Lamp * self )
{
if (self->lamp->id.flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static PyObject *Lamp_getType( BPy_Lamp * self )
{
PyObject *attr = PyInt_FromLong( self->lamp->type );
@@ -1154,28 +1083,6 @@ static PyObject *Lamp_getCol( BPy_Lamp * self )
return rgbTuple_getCol( self->color );
}
static int Lamp_setName( BPy_Lamp * self, PyObject * value )
{
char *name = NULL;
char buf[21];
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
rename_id( &self->lamp->id, buf );
return 0;
}
static int Lamp_setFakeUser( BPy_Lamp * self, PyObject * value )
{
return SetIdFakeUser(&self->lamp->id, value);
}
static int Lamp_setType( BPy_Lamp * self, PyObject * value )
{
return EXPP_setIValueRange ( value, &self->lamp->type,
@@ -1613,18 +1520,8 @@ static PyObject *Lamp_getTypesConst( void )
return attr;
}
static PyObject *Lamp_getUsers( BPy_Lamp * self )
{
return PyInt_FromLong( self->lamp->id.us );
}
/* #####DEPRECATED###### */
static PyObject *Lamp_oldsetName( BPy_Lamp * self, PyObject * args )
{
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setName );
}
static PyObject *Lamp_oldsetSamples( BPy_Lamp * self, PyObject * args )
{
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setSamples );

View File

@@ -58,6 +58,5 @@ PyObject *Lamp_Init( void );
PyObject *Lamp_CreatePyObject( struct Lamp *lamp );
Lamp *Lamp_FromPyObject( PyObject * pyobj );
int Lamp_CheckPyObject( PyObject * pyobj );
Lamp *GetLampByName( char *name );
#endif /* EXPP_LAMP_H */

View File

@@ -86,8 +86,6 @@ struct PyMethodDef M_Lattice_methods[] = {
/*****************************************************************************/
/* Python BPy_Lattice methods declarations: */
/*****************************************************************************/
static PyObject *Lattice_getName( BPy_Lattice * self );
static PyObject *Lattice_setName( BPy_Lattice * self, PyObject * args );
static PyObject *Lattice_setPartitions( BPy_Lattice * self, PyObject * args );
static PyObject *Lattice_getPartitions( BPy_Lattice * self );
static PyObject *Lattice_getKey( BPy_Lattice * self );
@@ -146,9 +144,9 @@ static char Lattice_copy_doc[] =
/*****************************************************************************/
static PyMethodDef BPy_Lattice_methods[] = {
/* name, method, flags, doc */
{"getName", ( PyCFunction ) Lattice_getName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
Lattice_getName_doc},
{"setName", ( PyCFunction ) Lattice_setName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
Lattice_setName_doc},
{"setPartitions", ( PyCFunction ) Lattice_setPartitions, METH_VARARGS,
Lattice_setPartitions_doc},
@@ -373,33 +371,6 @@ PyObject *Lattice_Init( void )
return ( mod );
}
//***************************************************************************
// Python BPy_Lattice methods:
//***************************************************************************
static PyObject *Lattice_getName( BPy_Lattice * self )
{
PyObject *attr = PyString_FromString( self->Lattice->id.name + 2 );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Lattice.name attribute" );
}
static PyObject *Lattice_setName( BPy_Lattice * self, PyObject * args )
{
char *name;
if( !PyArg_ParseTuple( args, "s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" ) );
rename_id( &self->Lattice->id, name );
Py_RETURN_NONE;
}
static PyObject *Lattice_setPartitions( BPy_Lattice * self, PyObject * args )
{
int x = 0;
@@ -839,7 +810,7 @@ static int Lattice_setAttr( BPy_Lattice * self, char *name, PyObject * value )
"LatticeSetAttr: couldn't create PyTuple" );
if( strcmp( name, "name" ) == 0 )
error = Lattice_setName( self, valtuple );
error = GenericLib_setName_with_method( self, valtuple );
else { // Error: no such member in the Lattice Data structure
/*Py_DECREF( value ); borrowed reference, no need to decref */
Py_DECREF( valtuple );

View File

@@ -263,23 +263,11 @@ static PyObject *M_Material_Get( PyObject * self, PyObject * args )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument (or nothing)" ) );
mat_iter = G.main->mat.first;
if( name ) { /* (name) - Search material by name */
BPy_Material *wanted_mat = NULL;
mat_iter = ( Material * ) GetIdFromList( &( G.main->mat ), name );
while( mat_iter ) {
if( strcmp( name, mat_iter->id.name + 2 ) == 0 ) {
wanted_mat =
( BPy_Material * )
Material_CreatePyObject( mat_iter );
break;
}
mat_iter = mat_iter->id.next;
}
if( wanted_mat == NULL ) { /* Requested material doesn't exist */
if( mat_iter == NULL ) { /* Requested material doesn't exist */
char error_msg[64];
PyOS_snprintf( error_msg, sizeof( error_msg ),
"Material \"%s\" not found", name );
@@ -287,19 +275,20 @@ static PyObject *M_Material_Get( PyObject * self, PyObject * args )
error_msg );
}
return ( PyObject * ) wanted_mat;
return Material_CreatePyObject( mat_iter );
}
else { /* () - return a list with all materials in the scene */
int index = 0;
PyObject *matlist, *pyobj;
matlist = PyList_New( BLI_countlist( &( G.main->mat ) ) );
if( !matlist )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyList" ) );
mat_iter = G.main->mat.first;
while( mat_iter ) {
pyobj = Material_CreatePyObject( mat_iter );
@@ -443,7 +432,6 @@ static PyObject *Matr_oldsetHaloSeed( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetHaloSize( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetHardness( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetIOR( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetName( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetNFlares( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetNLines( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetNRings( BPy_Material * self, PyObject * args );
@@ -474,7 +462,7 @@ static PyObject *Matr_oldsetRms( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetTranslucency( BPy_Material * self, PyObject * args );
static int Material_setIpo( BPy_Material * self, PyObject * value );
static int Material_setName( BPy_Material * self, PyObject * value );
static int Material_setMode( BPy_Material * self, PyObject * value );
static int Material_setRGBCol( BPy_Material * self, PyObject * value );
static int Material_setSpecCol( BPy_Material * self, PyObject * value );
@@ -527,15 +515,11 @@ static int Material_setRefracIndex( BPy_Material * self, PyObject * value );
static int Material_setRms( BPy_Material * self, PyObject * value );
static int Material_setFilter( BPy_Material * self, PyObject * value );
static int Material_setTranslucency( BPy_Material * self, PyObject * value );
static int Material_setFakeUser( BPy_Material * self, PyObject * value );
static PyObject *Material_getColorComponent( BPy_Material * self,
void * closure );
static PyObject *Material_getOopsLoc( BPy_Material * self );
static PyObject *Material_getOopsSel( BPy_Material * self );
static PyObject *Material_getLib( BPy_Material * self );
static PyObject *Material_getUsers( BPy_Material * self );
static PyObject *Material_getFakeUser( BPy_Material * self );
/*static int Material_setSeptex( BPy_Material * self, PyObject * value );
static PyObject *Material_getSeptex( BPy_Material * self );*/
@@ -543,7 +527,6 @@ static PyObject *Material_getFakeUser( BPy_Material * self );
/* Python BPy_Material methods declarations: */
/*****************************************************************************/
static PyObject *Material_getIpo( BPy_Material * self );
static PyObject *Material_getName( BPy_Material * self );
static PyObject *Material_getMode( BPy_Material * self );
static PyObject *Material_getRGBCol( BPy_Material * self );
/*static PyObject *Material_getAmbCol(BPy_Material *self);*/
@@ -608,7 +591,6 @@ 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 );
static PyObject *Material_getProperties( BPy_Material * self );
/*****************************************************************************/
@@ -616,9 +598,7 @@ static PyObject *Material_getProperties( BPy_Material * self );
/*****************************************************************************/
static PyMethodDef BPy_Material_methods[] = {
/* name, method, flags, doc */
{"getProperties", ( PyCFunction) Material_getProperties, METH_NOARGS,
"() Return Material's ID Properties"},
{"getName", ( PyCFunction ) Material_getName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"() - Return Material's name"},
{"getIpo", ( PyCFunction ) Material_getIpo, METH_NOARGS,
"() - Return Material's ipo or None if not found"},
@@ -716,7 +696,7 @@ static PyMethodDef BPy_Material_methods[] = {
{"getTextures", ( PyCFunction ) Material_getTextures, METH_NOARGS,
"() - Return Material's texture list as a tuple"},
{"setName", ( PyCFunction ) Matr_oldsetName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"(s) - Change Material's name"},
{"setIpo", ( PyCFunction ) Matr_oldsetIpo, METH_VARARGS,
"(Blender Ipo) - Change Material's Ipo"},
@@ -844,6 +824,7 @@ static PyMethodDef BPy_Material_methods[] = {
/*****************************************************************************/
static PyGetSetDef BPy_Material_getseters[] = {
GENERIC_LIB_GETSETATTR,
{"add",
(getter)Material_getAdd, (setter)Material_setAdd,
"Strength of the add effect",
@@ -961,10 +942,6 @@ static PyGetSetDef BPy_Material_getseters[] = {
(getter)Material_getMode, (setter)Material_setMode,
"Material mode bitmask",
NULL},
{"name",
(getter)Material_getName, (setter)Material_setName,
"Material data name",
NULL},
{"nFlares",
(getter)Material_getNFlares, (setter)Material_setNFlares,
"Number of subflares with halo",
@@ -1085,20 +1062,6 @@ static PyGetSetDef BPy_Material_getseters[] = {
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
"Diffuse color blue component",
(void *) EXPP_MAT_COMP_B },
{"users",
(getter)Material_getUsers, (setter)NULL,
"Number of material users",
NULL},
{"fakeUser",
(getter)Material_getFakeUser, (setter)Material_setFakeUser,
"The fake user status of this material",
NULL},
{"lib",
(getter)Material_getLib, (setter)NULL,
"Materials external library",
NULL},
{"properties", (getter) Material_getProperties, (setter)NULL,
"Get material's ID properties"},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
@@ -1271,40 +1234,6 @@ Material *Material_FromPyObject( PyObject * pyobj )
return ( ( BPy_Material * ) pyobj )->material;
}
/*****************************************************************************/
/* Description: Returns the object with the name specified by the argument */
/* name. Note that the calling function has to remove the first */
/* two characters of the object name. These two characters */
/* specify the type of the object (OB, ME, WO, ...) */
/* The function will return NULL when no object with the given */
/* name is found. */
/*****************************************************************************/
Material *GetMaterialByName( char *name )
{
Material *mat_iter;
mat_iter = G.main->mat.first;
while( mat_iter ) {
if( StringEqual( name, GetIdName( &( mat_iter->id ) ) ) ) {
return ( mat_iter );
}
mat_iter = mat_iter->id.next;
}
/* There is no material with the given name */
return ( NULL );
}
/*****************************************************************************/
/* Python BPy_Material methods: */
/*****************************************************************************/
static PyObject *Material_getProperties( BPy_Material * self )
{
/*sanity check, we set parent property type to Group here*/
return BPy_Wrap_IDProperty( (ID*)self->material, IDP_GetProperties((ID*)self->material, 1), NULL );
}
static PyObject *Material_getIpo( BPy_Material * self )
{
Ipo *ipo = self->material->ipo;
@@ -1315,17 +1244,6 @@ static PyObject *Material_getIpo( BPy_Material * self )
return Ipo_CreatePyObject( ipo );
}
static PyObject *Material_getName( BPy_Material * self )
{
PyObject *attr = PyString_FromString( self->material->id.name + 2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.name attribute" ) );
}
static PyObject *Material_getMode( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->mode );
@@ -2010,20 +1928,6 @@ static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args )
Py_RETURN_NONE;
}
static int Material_setName( BPy_Material * self, PyObject * value )
{
char *name;
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
rename_id( &self->material->id, name );
return 0;
}
static int Material_setMode( BPy_Material * self, PyObject * value )
{
int param;
@@ -2850,30 +2754,6 @@ static int Material_setOopsSel ( BPy_Material * self, PyObject * value )
return 0;
}
static PyObject *Material_getLib(BPy_Material *self)
{
return EXPP_GetIdLib((ID *)self->material);
}
static PyObject *Material_getUsers( BPy_Material * self )
{
return PyInt_FromLong( self->material->id.us );
}
static PyObject *Material_getFakeUser( BPy_Material * self )
{
if (self->material->id.flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Material_setFakeUser( BPy_Material * self, PyObject * value )
{
return SetIdFakeUser(&self->material->id, value);
}
/* #####DEPRECATED###### */
static PyObject *Matr_oldsetAdd( BPy_Material * self, PyObject * args )
@@ -2979,11 +2859,6 @@ static PyObject *Matr_oldsetIOR( BPy_Material * self, PyObject * args )
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setIOR );
}
static PyObject *Matr_oldsetName( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setName );
}
static PyObject *Matr_oldsetNFlares( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setNFlares );
@@ -3234,3 +3109,4 @@ static PyObject *Material_clearIpo( BPy_Material * self )
}
return EXPP_incr_ret_False(); /* no ipo found */
}

View File

@@ -7159,60 +7159,6 @@ static int Mesh_setSubDivLevels( BPy_Mesh *self, PyObject *value )
return 0;
}
static PyObject *Mesh_getName( BPy_Mesh * self )
{
PyObject *attr = PyString_FromString( self->mesh->id.name + 2 );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Mesh.name attribute" );
}
static int Mesh_setName( BPy_Mesh * self, PyObject * value )
{
char *name;
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
rename_id( &self->mesh->id, name );
return 0;
}
static PyObject *Mesh_getUsers( BPy_Mesh * self )
{
PyObject *attr = PyInt_FromLong( self->mesh->id.us );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Mesh.users attribute" );
}
static PyObject *Mesh_getLib(BPy_Mesh *self)
{
return EXPP_GetIdLib((ID *)self->mesh);
}
static PyObject *Mesh_getFakeUser( BPy_Mesh * self )
{
if (self->mesh->id.flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Mesh_setFakeUser( BPy_Mesh * self, PyObject * value )
{
return SetIdFakeUser(&self->mesh->id, value);
}
static PyObject *Mesh_getFlag( BPy_Mesh * self, void *type )
{
PyObject *attr;
@@ -7589,19 +7535,11 @@ static PyObject *Mesh_repr( BPy_Mesh * self )
self->mesh->id.name + 2 );
}
static PyObject *Mesh_getProperties( BPy_Mesh * self )
{
/*sanity check, we set parent property type to Group here*/
return BPy_Wrap_IDProperty( (ID*)self->mesh, IDP_GetProperties((ID*)self->mesh, 1), NULL );
}
/*****************************************************************************/
/* Python Mesh_Type attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Mesh_getseters[] = {
{"properties",
(getter)Mesh_getProperties, NULL,
"get the ID properties associated with this mesh"},
GENERIC_LIB_GETSETATTR,
{"verts",
(getter)Mesh_getVerts, (setter)Mesh_setVerts,
"The mesh's vertices (MVert)",
@@ -7630,10 +7568,6 @@ static PyGetSetDef BPy_Mesh_getseters[] = {
(getter)Mesh_getSubDivLevels, (setter)Mesh_setSubDivLevels,
"The display and rendering subdivision levels",
NULL},
{"name",
(getter)Mesh_getName, (setter)Mesh_setName,
"The mesh's data name",
NULL},
{"mode",
(getter)Mesh_getMode, (setter)Mesh_setMode,
"The mesh's mode bitfield",
@@ -7662,18 +7596,6 @@ static PyGetSetDef BPy_Mesh_getseters[] = {
(getter)Mesh_getActiveFace, (setter)Mesh_setActiveFace,
"Index of the mesh's active texture face (in UV editor)",
NULL},
{"users",
(getter)Mesh_getUsers, (setter)NULL,
"Number of users of the mesh",
NULL},
{"lib",
(getter)Mesh_getLib, (setter)NULL,
"Meshes external library",
NULL},
{"fakeUser",
(getter)Mesh_getFakeUser, (setter)Mesh_setFakeUser,
"The fake user status of this mesh",
NULL},
{"activeGroup",
(getter)Mesh_getActiveGroup, (setter)Mesh_setActiveGroup,
"Active group for the mesh",

View File

@@ -106,9 +106,6 @@ static PyObject *M_MetaElem_TypesDict( void )
/* Python BPy_Metaball methods declarations: */
/*****************************************************************************/
static PyObject *Metaball_getElements( BPy_Metaball * self );
static PyObject *Metaball_getName( BPy_Metaball * self );
static PyObject *Metaball_getLib( BPy_Metaball * self );
static int Metaball_setName( BPy_Metaball * self, PyObject * value );
static PyObject *Metaball_getMaterials( BPy_Metaball * self );
static int Metaball_setMaterials( BPy_Metaball * self, PyObject * value );
static PyObject *Metaball_getWiresize( BPy_Metaball * self );
@@ -118,9 +115,6 @@ static int Metaball_setRendersize( BPy_Metaball * self, PyObject * value);
static PyObject *Metaball_getThresh( BPy_Metaball * self );
static int Metaball_setThresh( BPy_Metaball * self, PyObject * args );
static PyObject *Metaball_copy( BPy_Metaball * self );
static PyObject *Metaball_getUsers( BPy_Metaball * self );
static PyObject *Metaball_getFakeUser( BPy_Metaball * self );
static int Metaball_setFakeUser( BPy_Metaball * self, PyObject * value );
/*****************************************************************************/
/* Python BPy_Metaball methods table: */
@@ -173,22 +167,7 @@ static int Metaelem_setMFlagBits( BPy_Metaelem * self, PyObject * value, void *
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Metaball_getseters[] = {
{"name",
(getter)Metaball_getName, (setter)Metaball_setName,
"Metaball name",
NULL},
{"lib",
(getter)Metaball_getLib, (setter)NULL,
"Metaballs external library",
NULL},
{"users",
(getter)Metaball_getUsers, (setter)NULL,
"Number of metaball users",
NULL},
{"fakeUser",
(getter)Metaball_getFakeUser, (setter)Metaball_setFakeUser,
"The fake user status of this object",
NULL},
GENERIC_LIB_GETSETATTR,
{"materials",
(getter)Metaball_getMaterials, (setter)Metaball_setMaterials,
"Number of metaball users",
@@ -550,35 +529,6 @@ MetaBall *Metaball_FromPyObject( PyObject * pyobj )
return ( ( BPy_Metaball * ) pyobj )->metaball;
}
static PyObject *Metaball_getName( BPy_Metaball * self )
{
PyObject *attr = PyString_FromString( self->metaball->id.name + 2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Metaball.name attribute" ) );
}
static int Metaball_setName( BPy_Metaball * self, PyObject * value )
{
char *name = NULL;
name = PyString_AsString ( value );
if( !name )
return ( EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" ) );
rename_id( &self->metaball->id, name );
return 0;
}
static PyObject *Metaball_getLib( BPy_Metaball * self )
{
return EXPP_GetIdLib((ID *)self->metaball);
}
static PyObject *Metaball_getMaterials( BPy_Metaball *self )
{
return EXPP_PyList_fromMaterialList( self->metaball->mat,
@@ -683,27 +633,6 @@ static int Metaball_setThresh( BPy_Metaball * self, PyObject * value )
return 0;
}
static PyObject *Metaball_getUsers( BPy_Metaball * self )
{
return PyInt_FromLong( self->metaball->id.us );
}
static PyObject *Metaball_getFakeUser( BPy_Metaball * self )
{
if (self->metaball->id.flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Metaball_setFakeUser( BPy_Metaball * self, PyObject * value )
{
return SetIdFakeUser(&self->metaball->id, value);
}
static PyObject *Metaball_copy( BPy_Metaball * self )
{
BPy_Metaball *pymball; /* for Data object wrapper in Python */

View File

@@ -84,8 +84,6 @@ struct PyMethodDef M_NLA_methods[] = {
/*****************************************************************************/
/* Python BPy_Action methods declarations: */
/*****************************************************************************/
static PyObject *Action_getName( BPy_Action * self );
static PyObject *Action_setName( BPy_Action * self, PyObject * args );
static PyObject *Action_setActive( BPy_Action * self, PyObject * args );
static PyObject *Action_getFrameNumbers(BPy_Action *self);
static PyObject *Action_getChannelIpo( BPy_Action * self, PyObject * args );
@@ -98,9 +96,9 @@ static PyObject *Action_getAllChannelIpos( BPy_Action * self );
/*****************************************************************************/
static PyMethodDef BPy_Action_methods[] = {
/* name, method, flags, doc */
{"getName", ( PyCFunction ) Action_getName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"() - return Action name"},
{"setName", ( PyCFunction ) Action_setName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"(str) - rename Action"},
{"setActive", ( PyCFunction ) Action_setActive, METH_VARARGS,
"(str) -set this action as the active action for an object"},
@@ -237,44 +235,6 @@ static PyObject *M_NLA_GetActions( PyObject * self_unused )
return dict;
}
/*----------------------------------------------------------------------*/
static PyObject *Action_getName( BPy_Action * self )
{
PyObject *attr = NULL;
if( !self->action )
( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get attribute from a NULL action" ) );
attr = PyString_FromString( self->action->id.name + 2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Action.name attribute" ) );
}
/*----------------------------------------------------------------------*/
static PyObject *Action_setName( BPy_Action * self, PyObject * args )
{
char *name;
if( !self->action )
( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get attribute from a NULL action" ) );
if( !PyArg_ParseTuple( args, "s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected string argument" ) );
/*change name*/
rename_id( &self->action->id, name);
Py_RETURN_NONE;
}
static PyObject *Action_getFrameNumbers(BPy_Action *self)
{
bActionChannel *achan = NULL;
@@ -446,7 +406,7 @@ static PyObject *Action_getAttr( BPy_Action * self, char *name )
PyObject *attr = Py_None;
if( strcmp( name, "name" ) == 0 )
attr = Action_getName( self );
attr = GenericLib_getName( self );
else if( strcmp( name, "__members__" ) == 0 ) {
attr = Py_BuildValue( "[s]", "name" );
}
@@ -475,7 +435,7 @@ static int Action_setAttr( BPy_Action * self, char *name, PyObject * value )
"ActionSetAttr: couldn't create tuple" );
if( strcmp( name, "name" ) == 0 )
error = Action_setName( self, valtuple );
error = GenericLib_setName_with_method( self, valtuple );
else { /* Error */
Py_DECREF( valtuple );

View File

@@ -346,8 +346,6 @@ static PyObject *Object_getIpo( BPy_Object * self );
static PyObject *Object_getLocation( BPy_Object * self, PyObject * args );
static PyObject *Object_getMaterials( BPy_Object * self, PyObject * args );
static PyObject *Object_getMatrix( BPy_Object * self, PyObject * args );
static PyObject *Object_getName( BPy_Object * self );
static PyObject *Object_getLib( BPy_Object * self );
static PyObject *Object_getParent( BPy_Object * self );
static PyObject *Object_getParentBoneName( BPy_Object * self );
static int Object_setParentBoneName( BPy_Object * self, PyObject * value );
@@ -382,7 +380,6 @@ static PyObject *Object_insertCurrentPoseKey( BPy_Object * self, PyObject * args
static PyObject *Object_setConstraintInfluenceForBone( BPy_Object * self, PyObject * args );
static PyObject *Object_setLocation( BPy_Object * self, PyObject * args );
static PyObject *Object_setMaterials( BPy_Object * self, PyObject * args );
static PyObject *Object_SetName( BPy_Object * self, PyObject * args );
static PyObject *Object_setSize( BPy_Object * self, PyObject * args );
static PyObject *Object_setTimeOffset( BPy_Object * self, PyObject * args );
static PyObject *Object_makeTrack( BPy_Object * self, PyObject * args );
@@ -514,7 +511,7 @@ or old_worldspace.\n\
matrix is not updated for changes made by the script itself\n\
(like obj.LocX = 10) until a redraw happens, either called by the script or\n\
automatic when the script finishes."},
{"getName", ( PyCFunction ) Object_getName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"Returns the name of the object"},
{"getParent", ( PyCFunction ) Object_getParent, METH_NOARGS,
"Returns the object's parent object"},
@@ -695,7 +692,7 @@ triple."},
{"setMaterials", ( PyCFunction ) Object_setMaterials, METH_VARARGS,
"Sets materials. The argument must be a list of valid material\n\
objects."},
{"setName", ( PyCFunction ) Object_SetName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"Sets the name of the object"},
{"setSize", ( PyCFunction ) Object_setSize, METH_VARARGS,
"Set the object's size. The first argument must be a vector\n\
@@ -866,7 +863,7 @@ PyObject *M_Object_Get( PyObject * self_unused, PyObject * args )
PyArg_ParseTuple( args, "|s", &name );
if( name != NULL ) {
object = GetObjectByName( name );
object = ( Object * ) GetIdFromList( &( G.main->object ), name );
/* No object exists with the name specified in the argument name. */
if( !object ){
@@ -1319,16 +1316,6 @@ static PyObject *Object_getMaterials( BPy_Object * self, PyObject * args )
self->object->totcol, all );
}
static PyObject *Object_getName( BPy_Object * self )
{
return PyString_FromString( self->object->id.name + 2 );
}
static PyObject *Object_getLib( BPy_Object * self )
{
return EXPP_GetIdLib((ID *)self->object);
}
static PyObject *Object_getParent( BPy_Object * self )
{
if( self->object->parent )
@@ -2620,20 +2607,6 @@ static PyObject *Object_setMaterials( BPy_Object * self, PyObject * args )
Py_RETURN_NONE;
}
static int Object_setName( BPy_Object * self, PyObject * args )
{
char *name;
name = PyString_AsString ( args );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a string argument" );
rename_id( &self->object->id, name );
return 0;
}
static PyObject *Object_setSize( BPy_Object * self, PyObject * args )
{
float sizex;
@@ -3158,30 +3131,6 @@ struct Object *Object_FromPyObject( PyObject * py_obj )
return ( blen_obj->object );
}
/*****************************************************************************/
/* Description: Returns the object with the name specified by the argument */
/* name. Note that the calling function has to remove the first */
/* two characters of the object name. These two characters */
/* specify the type of the object (OB, ME, WO, ...) */
/* The function will return NULL when no object with the given */
/* name is found. */
/*****************************************************************************/
Object *GetObjectByName( char *name )
{
Object *obj_iter;
obj_iter = G.main->object.first;
while( obj_iter ) {
if( StringEqual( name, GetIdName( &( obj_iter->id ) ) ) ) {
return ( obj_iter );
}
obj_iter = obj_iter->id.next;
}
/* There is no object with the given name */
return ( NULL );
}
/*****************************************************************************/
/* Function: Object_dealloc */
/* Description: This is a callback function for the BlenObject type. It is */
@@ -4499,24 +4448,6 @@ static int Object_setTracked( BPy_Object * self, PyObject * value )
return 0;
}
static PyObject *Object_getUsers( BPy_Object * self )
{
return PyInt_FromLong( self->object->id.us );
}
static PyObject *Object_getFakeUser( BPy_Object * self )
{
if (self->object->id.flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Object_setFakeUser( BPy_Object * self, PyObject * value )
{
return SetIdFakeUser(&self->object->id, value);
}
/* Localspace matrix */
static PyObject *Object_getMatrixLocal( BPy_Object * self )
@@ -4745,6 +4676,7 @@ static PyObject *Object_getRBHalfExtents( BPy_Object * self )
}
static PyGetSetDef BPy_Object_getseters[] = {
GENERIC_LIB_GETSETATTR,
{"LocX",
(getter)getFloatAttr, (setter)setFloatAttr,
"The X location coordinate of the object",
@@ -4918,14 +4850,6 @@ static PyGetSetDef BPy_Object_getseters[] = {
(getter)Object_getMatrixOldWorld, (setter)NULL,
"old-type worldspace matrix (prior to Blender 2.34)",
NULL},
{"name",
(getter)Object_getName, (setter)Object_setName,
"Object data name",
NULL},
{"lib",
(getter)Object_getLib, (setter)NULL,
"Objects linked library",
NULL},
{"oopsLoc",
(getter)Object_getOopsLoc, (setter)Object_setOopsLoc,
"Object OOPs location",
@@ -4974,14 +4898,6 @@ static PyGetSetDef BPy_Object_getseters[] = {
(getter)Object_getAllProperties, (setter)NULL,
"The object's properties",
NULL},
{"users",
(getter)Object_getUsers, (setter)NULL,
"The number of object users",
NULL},
{"fakeUser",
(getter)Object_getFakeUser, (setter)Object_setFakeUser,
"The fake user status of this object",
NULL},
{"piFalloff",
(getter)getFloatAttr, (setter)setFloatAttrClamp,
@@ -5533,12 +5449,6 @@ static PyObject *Object_SetDrawType( BPy_Object * self, PyObject * args )
(setter)Object_setDrawType );
}
static PyObject *Object_SetName( BPy_Object * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args,
(setter)Object_setName );
}
static PyObject *Object_SetMatrix( BPy_Object * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args,

View File

@@ -55,7 +55,6 @@ PyObject *Object_Init( void );
PyObject *Object_CreatePyObject( struct Object *obj );
Object *Object_FromPyObject( PyObject * py_obj );
int Object_CheckPyObject( PyObject * py_obj );
Object *GetObjectByName( char *name );
void Object_updateDag( void *data );

View File

@@ -125,8 +125,6 @@ struct PyMethodDef M_Scene_methods[] = {
{NULL, NULL, 0, NULL}
};
/*-----------------------BPy_Scene method declarations--------------------*/
static PyObject *Scene_oldgetName( BPy_Scene * self );
static PyObject *Scene_oldsetName( BPy_Scene * self, PyObject * arg );
static PyObject *Scene_getLayerList( BPy_Scene * self );
static PyObject *Scene_oldsetLayers( BPy_Scene * self, PyObject * arg );
static PyObject *Scene_copy( BPy_Scene * self, PyObject * arg );
@@ -158,9 +156,9 @@ static PyObject *SceneObSeq_CreatePyObject( BPy_Scene *self, Base *iter, int mod
/*-----------------------BPy_Scene method def------------------------------*/
static PyMethodDef BPy_Scene_methods[] = {
/* name, method, flags, doc */
{"getName", ( PyCFunction ) Scene_oldgetName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"() - Return Scene name"},
{"setName", ( PyCFunction ) Scene_oldsetName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"(str) - Change Scene name"},
{"getLayers", ( PyCFunction ) Scene_getLayerList, METH_NOARGS,
"() - Return a list of layers int indices which are set in this scene "},
@@ -230,66 +228,8 @@ static PyMethodDef BPy_Scene_methods[] = {
/*****************************************************************************/
/* Python BPy_Scene methods: */
/* Python BPy_Scene getsetattr funcs: */
/*****************************************************************************/
static PyObject *Scene_getName( BPy_Scene * self )
{
PyObject *attr;
SCENE_DEL_CHECK_PY(self);
attr = PyString_FromString( self->scene->id.name + 2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Scene.name attribute" ) );
}
static int Scene_setName( BPy_Scene * self, PyObject * value )
{
char *name = NULL;
SCENE_DEL_CHECK_INT(self);
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
rename_id( &self->scene->id, name );
return 0;
}
static PyObject *Scene_getLib( BPy_Scene * self )
{
SCENE_DEL_CHECK_PY(self);
return EXPP_GetIdLib((ID *)self->scene);
}
static PyObject *Scene_getUsers( BPy_Scene * self )
{
SCENE_DEL_CHECK_PY(self);
return PyInt_FromLong( self->scene->id.us );
}
static PyObject *Scene_getFakeUser( BPy_Scene * self )
{
SCENE_DEL_CHECK_PY(self);
if (self->scene->id.flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Scene_setFakeUser( BPy_Scene * self, PyObject * value )
{
SCENE_DEL_CHECK_INT(self);
return SetIdFakeUser(&self->scene->id, value);
}
static PyObject *Scene_getLayerMask( BPy_Scene * self )
{
SCENE_DEL_CHECK_PY(self);
@@ -447,36 +387,11 @@ static PyObject *Scene_getObjects( BPy_Scene *self)
return SceneObSeq_CreatePyObject(self, NULL, 0);
}
static PyObject *Scene_GetProperties(BPy_Scene * self)
{
SCENE_DEL_CHECK_PY(self);
return BPy_Wrap_IDProperty( (ID*)self->scene, IDP_GetProperties((ID*)self->scene, 1), NULL );
}
/*****************************************************************************/
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Scene_getseters[] = {
{"name",
(getter)Scene_getName, (setter)Scene_setName,
"Scene name",
NULL},
{"lib",
(getter)Scene_getLib, (setter)NULL,
"Scenes external library path",
NULL},
{"users",
(getter)Scene_getUsers, (setter)NULL,
"Scenes user count",
NULL},
{"fakeUser",
(getter)Scene_getFakeUser, (setter)Scene_setFakeUser,
"Scene fake user state",
NULL},
{"properties",
(getter)Scene_GetProperties, (setter)NULL,
"Scene properties",
NULL},
GENERIC_LIB_GETSETATTR,
{"Layer",
(getter)Scene_getLayerMask, (setter)Scene_setLayerMask,
"Scene layer bitmask",
@@ -802,88 +717,11 @@ static PyObject *M_Scene_Unlink( PyObject * self, PyObject * args )
/* DEPRECATE ME !!! */
/*-----------------------BPy_Scene function defintions-------------------*/
/*-----------------------Scene.getName()---------------------------------*/
static PyObject *Scene_oldgetName( BPy_Scene * self )
{
PyObject *attr;
SCENE_DEL_CHECK_PY(self);
attr= PyString_FromString( self->scene->id.name + 2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Scene.name attribute" ) );
}
/*-----------------------Scene.setName()---------------------------------*/
static PyObject *Scene_oldsetName( BPy_Scene * self, PyObject * args )
{
char *name;
SCENE_DEL_CHECK_PY(self);
if( !PyArg_ParseTuple( args, "s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" ) );
rename_id( &self->scene->id, name );
Py_RETURN_NONE;
}
/*-----------------------Scene.setLayers()---------------------------------*/
static PyObject *Scene_oldsetLayers( BPy_Scene * self, PyObject * args )
{
PyObject *list = NULL, *item = NULL;
int layers = 0, val, i, len_list;
SCENE_DEL_CHECK_PY(self);
if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &list ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a list of integers in the range [1, 20]" ) );
len_list = PyList_Size(list);
if (len_list == 0)
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"list can't be empty, at least one layer must be set" ) );
for( i = 0; i < len_list; i++ ) {
item = PyList_GetItem( list, i );
if( !PyInt_Check( item ) )
return EXPP_ReturnPyObjError
( PyExc_AttributeError,
"list must contain only integer numbers" );
val = ( int ) PyInt_AsLong( item );
if( val < 1 || val > 20 )
return EXPP_ReturnPyObjError
( PyExc_AttributeError,
"layer values must be in the range [1, 20]" );
layers |= 1 << ( val - 1 );
}
self->scene->lay = layers;
if (G.vd && (self->scene == G.scene)) {
int bit = 0;
G.vd->lay = layers;
while( bit < 20 ) {
val = 1 << bit;
if( layers & val ) {
G.vd->layact = val;
break;
}
bit++;
}
}
Py_RETURN_NONE;
return EXPP_setterWrapper( (void *)self, args, (setter)Scene_setLayerList );
}
/* END DEPRECATE CODE */

View File

@@ -95,10 +95,8 @@ static int Text_IsLinked( BPy_Text * self );
/*****************************************************************************/
/* Python BPy_Text methods declarations: */
/*****************************************************************************/
static PyObject *Text_getName( BPy_Text * self );
static PyObject *Text_getFilename( BPy_Text * self );
static PyObject *Text_getNLines( BPy_Text * self );
static PyObject *Text_setName( BPy_Text * self, PyObject * args );
static PyObject *Text_clear( BPy_Text * self );
static PyObject *Text_write( BPy_Text * self, PyObject * args );
static PyObject *Text_set( BPy_Text * self, PyObject * args );
@@ -110,13 +108,13 @@ static PyObject *Text_makeCurrent( BPy_Text * self );
/*****************************************************************************/
static PyMethodDef BPy_Text_methods[] = {
/* name, method, flags, doc */
{"getName", ( PyCFunction ) Text_getName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"() - Return Text Object name"},
{"getFilename", ( PyCFunction ) Text_getFilename, METH_VARARGS,
"() - Return Text Object filename"},
{"getNLines", ( PyCFunction ) Text_getNLines, METH_VARARGS,
"() - Return number of lines in text buffer"},
{"setName", ( PyCFunction ) Text_setName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"(str) - Change Text Object name"},
{"clear", ( PyCFunction ) Text_clear, METH_NOARGS,
"() - Clear Text buffer"},
@@ -381,17 +379,6 @@ PyObject *Text_CreatePyObject( Text * txt )
/*****************************************************************************/
/* Python BPy_Text methods: */
/*****************************************************************************/
static PyObject *Text_getName( BPy_Text * self )
{
PyObject *attr = PyString_FromString( self->text->id.name + 2 );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Text.name attribute" );
}
static PyObject *Text_getFilename( BPy_Text * self )
{
PyObject *attr;
@@ -433,19 +420,6 @@ static PyObject *Text_getNLines( BPy_Text * self )
"couldn't get Text.nlines attribute" );
}
static PyObject *Text_setName( BPy_Text * self, PyObject * args )
{
char *name;
if( !PyArg_ParseTuple( args, "s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" ) );
rename_id( &self->text->id, name );
Py_RETURN_NONE;
}
static PyObject *Text_clear( BPy_Text * self)
{
int oldstate;
@@ -618,7 +592,7 @@ static int Text_setAttr( BPy_Text * self, char *name, PyObject * value )
"TextSetAttr: couldn't create PyTuple" );
if( strcmp( name, "name" ) == 0 )
error = Text_setName( self, valtuple );
error = GenericLib_setName_with_method( self, valtuple );
else { /* Error: no such member in the Text Data structure */
Py_DECREF( value );
Py_DECREF( valtuple );

View File

@@ -389,7 +389,6 @@ struct PyMethodDef M_Texture_methods[] = {
#if 0
GETFUNC( getExtend );
GETFUNC( getImage );
GETFUNC( getName );
GETFUNC( getType );
GETFUNC( getSType );
GETFUNC( clearIpo );
@@ -402,7 +401,6 @@ SETFUNC( setAnimMontage );
GETFUNC( oldgetSType );
GETFUNC( oldgetType );
GETFUNC(getProperties);
GETFUNC( clearIpo );
GETFUNC( getAnimFrames );
GETFUNC( getAnimOffset );
@@ -423,7 +421,6 @@ GETFUNC( getImage );
GETFUNC( getIpo );
GETFUNC( getIScale );
GETFUNC( getLacunarity );
GETFUNC( getName );
GETFUNC( getNoiseBasis );
GETFUNC( getNoiseDepth );
GETFUNC( getNoiseSize );
@@ -447,7 +444,6 @@ OLDSETFUNC( setFlags );
OLDSETFUNC( setImage );
OLDSETFUNC( setImageFlags );
OLDSETFUNC( setIpo );
OLDSETFUNC( setName );
OLDSETFUNC( setNoiseBasis );
OLDSETFUNC( setSType );
OLDSETFUNC( setType );
@@ -470,7 +466,6 @@ SETFUNC( setImage );
SETFUNC( setIpo );
SETFUNC( setIScale );
SETFUNC( setLacunarity );
SETFUNC( setName );
SETFUNC( setNoiseBasis );
SETFUNC( setNoiseDepth );
SETFUNC( setNoiseSize );
@@ -502,7 +497,7 @@ static PyMethodDef BPy_Texture_methods[] = {
"() - Return Texture extend mode"},
{"getImage", ( PyCFunction ) Texture_getImage, METH_NOARGS,
"() - Return Texture Image"},
{"getName", ( PyCFunction ) Texture_getName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"() - Return Texture name"},
{"getSType", ( PyCFunction ) Texture_oldgetSType, METH_NOARGS,
"() - Return Texture stype as string"},
@@ -522,7 +517,7 @@ static PyMethodDef BPy_Texture_methods[] = {
"(Blender Image) - Set Texture Image"},
{"setImageFlags", ( PyCFunction ) Texture_oldsetImageFlags, METH_VARARGS,
"(s,s,s,s,...) - Set Texture image flags"},
{"setName", ( PyCFunction ) Texture_oldsetName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"(s) - Set Texture name"},
{"setSType", ( PyCFunction ) Texture_oldsetSType, METH_VARARGS,
"(s) - Set Texture stype"},
@@ -541,9 +536,7 @@ static PyMethodDef BPy_Texture_methods[] = {
/* Python Texture_Type attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Texture_getseters[] = {
{"properties",
(getter)Texture_getProperties, NULL,
"Get this texture's ID Properties"},
GENERIC_LIB_GETSETATTR,
{"animFrames",
(getter)Texture_getAnimFrames, (setter)Texture_setAnimFrames,
"Number of frames of a movie to use",
@@ -630,10 +623,6 @@ static PyGetSetDef BPy_Texture_getseters[] = {
(getter)Texture_getLacunarity, (setter)Texture_setLacunarity,
"Gap between succesive frequencies (for Musgrave textures)",
NULL},
{"name",
(getter)Texture_getName, (setter)Texture_setName,
"Texture data name",
NULL},
{"noiseBasis",
(getter)Texture_getNoiseBasis, (setter)Texture_setNoiseBasis,
"Noise basis type (wood, stucci, marble, clouds, Musgrave, distorted noise)",
@@ -1332,12 +1321,6 @@ int Texture_CheckPyObject( PyObject * pyobj )
/* Python BPy_Texture methods: */
/*****************************************************************************/
static PyObject *Texture_getProperties( BPy_Texture * self )
{
/*sanity check, we set parent property type to Group here*/
return BPy_Wrap_IDProperty( (ID*)self->texture, IDP_GetProperties((ID*)self->texture, 1), NULL );
}
static PyObject *Texture_getExtend( BPy_Texture * self )
{
PyObject *attr = NULL;
@@ -1365,17 +1348,6 @@ static PyObject *Texture_getImage( BPy_Texture * self )
Py_RETURN_NONE;
}
static PyObject *Texture_getName( BPy_Texture * self )
{
PyObject *attr = PyString_FromString( self->texture->id.name + 2 );
if( !attr )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Texture.name attribute" );
return attr;
}
static PyObject *Texture_oldgetSType( BPy_Texture * self )
{
PyObject *attr = NULL;
@@ -1635,23 +1607,6 @@ static int Texture_setImageFlags( BPy_Texture * self, PyObject * value,
return 0;
}
static int Texture_setName( BPy_Texture * self, PyObject * value )
{
char *name;
char buf[21];
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
rename_id( &self->texture->id, buf );
return 0;
}
static int Texture_setNoiseDepth( BPy_Texture * self, PyObject * value )
{
short max = EXPP_TEX_NOISEDEPTH_MAX;
@@ -2453,12 +2408,6 @@ static PyObject *Texture_oldsetImage( BPy_Texture * self, PyObject * args )
(setter)Texture_setImage );
}
static PyObject *Texture_oldsetName( BPy_Texture * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args,
(setter)Texture_setName );
}
static PyObject *Texture_oldsetIpo( BPy_Texture * self, PyObject * args )
{
return EXPP_setterWrapper ( (void *)self, args, (setter)Texture_setIpo );

View File

@@ -73,8 +73,6 @@ static PyObject *World_getIpo( BPy_World * self );
static PyObject *World_setIpo( BPy_World * self, PyObject * args );
static PyObject *World_clearIpo( BPy_World * self );
static PyObject *World_insertIpoKey( BPy_World * self, PyObject * args );
static PyObject *World_getName( BPy_World * self );
static PyObject *World_setName( BPy_World * self, PyObject * args );
static PyObject *World_getMode( BPy_World * self );
static PyObject *World_setMode( BPy_World * self, PyObject * args );
static PyObject *World_getSkytype( BPy_World * self );
@@ -169,9 +167,9 @@ static PyMethodDef BPy_World_methods[] = {
"() - Change this World's ipo"},
{"clearIpo", ( PyCFunction ) World_clearIpo, METH_VARARGS,
"() - Unlink Ipo from this World"},
{"getName", ( PyCFunction ) World_getName, METH_NOARGS,
{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
"() - Return World Data name"},
{"setName", ( PyCFunction ) World_setName, METH_VARARGS,
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
"() - Set World Data name"},
{"getMode", ( PyCFunction ) World_getMode, METH_NOARGS,
"() - Return World Data mode"},
@@ -501,43 +499,6 @@ static PyObject *World_clearIpo( BPy_World * self )
return EXPP_incr_ret_False(); /* no ipo found */
}
/**
* \brief World PyMethod getName
*
* \return string: The World Data name.
*/
static PyObject *World_getName( BPy_World * self )
{
PyObject *attr = PyString_FromString( self->world->id.name + 2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get World.name attribute" ) );
}
/**
* \brief World PyMethod setName
* \param name - string: The new World Data name.
*/
static PyObject *World_setName( BPy_World * self, PyObject * args )
{
char *name = 0;
if( !PyArg_ParseTuple( args, "s", &name ) )
return ( EXPP_ReturnPyObjError
( PyExc_TypeError, "expected string argument" ) );
rename_id( &self->world->id, name );
Py_RETURN_NONE;
}
/**
* \brief World PyMethod getSkytype
*
@@ -935,7 +896,7 @@ static PyObject *World_GetAttr( BPy_World * self, char *name )
{
if( strcmp( name, "name" ) == 0 )
return World_getName( self );
return GenericLib_getName( self );
if( strcmp( name, "lib" ) == 0 )
return EXPP_GetIdLib((ID *)self->world);
if( strcmp( name, "skytype" ) == 0 )
@@ -975,7 +936,7 @@ static int World_SetAttr( BPy_World * self, char *name, PyObject * value )
return EXPP_ReturnIntError( PyExc_MemoryError,
"WorldSetAttr: couldn't parse args" );
else if( strcmp( name, "name" ) == 0 )
error = World_setName( self, valtuple );
error = GenericLib_setName_with_method( self, valtuple );
else if( strcmp( name, "skytype" ) == 0 )
error = World_setSkytype( self, valtuple );
else if( strcmp( name, "mode" ) == 0 )
@@ -1087,29 +1048,6 @@ World *World_FromPyObject( PyObject * py_obj )
}
/*****************************************************************************/
/* Description: Returns the object with the name specified by the argument */
/* name. Note that the calling function has to remove the first */
/* two characters of the object name. These two characters */
/* specify the type of the object (OB, ME, WO, ...) */
/* The function will return NULL when no object with the given */
/* name is found. */
/*****************************************************************************/
World *GetWorldByName( char *name )
{
World *world_iter;
world_iter = G.main->world.first;
while( world_iter ) {
if( StringEqual( name, GetIdName( &( world_iter->id ) ) ) ) {
return ( world_iter );
}
world_iter = world_iter->id.next;
}
/* There is no object with the given name */
return ( NULL );
}
/*
* World_insertIpoKey()
* inserts World IPO key for ZENITH,HORIZON,MIST,STARS,OFFSET,SIZE

View File

@@ -55,6 +55,5 @@ PyObject *World_Init( void );
PyObject *World_CreatePyObject( World * world );
World *World_FromPyObject( PyObject * pyobj );
int World_CheckPyObject( PyObject * pyobj );
World *GetWorldByName( char *name );
#endif /* EXPP_WORLD_H */

View File

@@ -25,7 +25,8 @@
*
* This is a new part of Blender.
*
* Contributor(s): Michel Selten, Willian P. Germano, Alex Mole, Ken Hughes
* Contributor(s): Michel Selten, Willian P. Germano, Alex Mole, Ken Hughes,
* Campbell Barton
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -974,3 +975,96 @@ int EXPP_dict_set_item_str( PyObject *dict, char *key, PyObject *value)
Py_DECREF( value ); /* delete original */
return ret;
}
/* Generic get/set attrs */
PyObject *GenericLib_getName( void *self )
{
ID *id = ((BPy_GenericLib *)self)->id;
if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
return PyString_FromString( id->name + 2 );
}
int GenericLib_setName( void *self, PyObject *value )
{
ID *id = ((BPy_GenericLib *)self)->id;
char *name = NULL;
if (!id) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "data has been removed" ) );
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
rename_id( &id, name );
return 0;
}
PyObject *GenericLib_getFakeUser( void *self )
{
ID *id = ((BPy_GenericLib *)self)->id;
if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
if (id->flag & LIB_FAKEUSER)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
int GenericLib_setFakeUser( void *self, PyObject *value )
{
int param;
ID *id = ((BPy_GenericLib *)self)->id;
if (!id) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "data has been removed" ) );
param = PyObject_IsTrue( value );
if( param == -1 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected int argument in range [0,1]" );
if (param) {
if (!(id->flag & LIB_FAKEUSER)) {
id->flag |= LIB_FAKEUSER;
id_us_plus(id);
}
} else {
if (id->flag & LIB_FAKEUSER) {
id->flag &= ~LIB_FAKEUSER;
id->us--;
}
}
}
/* read only */
PyObject *GenericLib_getLib( void *self )
{
ID *id = ((BPy_GenericLib *)self)->id;
if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
return EXPP_GetIdLib(id);
}
PyObject *GenericLib_getUsers( void *self )
{
ID *id = ((BPy_GenericLib *)self)->id;
if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
return PyInt_FromLong(id->us);
}
PyObject *GenericLib_getProperties( void *self )
{
ID *id = ((BPy_GenericLib *)self)->id;
if (!id) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "data has been removed" ) );
return BPy_Wrap_IDProperty( id, IDP_GetProperties(id, 1), NULL );
}
/* use for any.setName("name")*/
PyObject * GenericLib_setName_with_method( void *self, PyObject *args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)GenericLib_setName );
}

View File

@@ -159,5 +159,53 @@ void EXPP_allqueue(unsigned short event, short val);
/* helper to keep dictionaries from causing memory leaks */
int EXPP_dict_set_item_str( PyObject *dict, char *key, PyObject *value);
#endif /* EXPP_gen_utils_h */
/* Dummy struct for getting the ID from a libdata BPyObject */
typedef struct {
PyObject_HEAD /* required python macro */
ID *id;
} BPy_GenericLib;
/* ID functions for all libdata */
#define GENERIC_LIB_GETSETATTR \
{"name",\
(getter)GenericLib_getName, (setter)GenericLib_setName,\
"name",\
NULL},\
{"lib",\
(getter)GenericLib_getLib, (setter)NULL,\
"external library path",\
NULL},\
{"users",\
(getter)GenericLib_getUsers, (setter)NULL,\
"user count",\
NULL},\
{"fakeUser",\
(getter)GenericLib_getFakeUser, (setter)GenericLib_setFakeUser,\
"fake user state",\
NULL},\
{"properties",\
(getter)GenericLib_getProperties, (setter)NULL,\
"properties",\
NULL}
int GenericLib_setName( void *self, PyObject *value );
PyObject *GenericLib_getName( void *self );
PyObject *GenericLib_getFakeUser( void *self );
int GenericLib_setFakeUser( void *self, PyObject *value );
PyObject *GenericLib_getLib( void *self );
PyObject *GenericLib_getUsers( void *self );
PyObject *GenericLib_getProperties( void *self );
/* use this for oldstyle somedata.getName("name") */
PyObject * GenericLib_setName_with_method( void *self, PyObject *value );
#endif /* EXPP_gen_utils_h */