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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user