=ID Properties Update=
This commit adds file reading/writing of ID properties to all ID types, and also adds python access for NMesh, Mesh, Scene and Image. Note that the file reading code might need some more work for certain future/planned features to save right. Also I updated a few comments in idprop.c.
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include "DNA_packedFile_types.h"
|
||||
#include "BKE_icons.h"
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IDProp.h"
|
||||
|
||||
/* used so we can get G.scene->r.cfra for getting the
|
||||
current image frame, some images change frame if they are a sequence */
|
||||
@@ -1150,6 +1151,8 @@ static PyObject *Image_getAttr( BPy_Image * self, char *name )
|
||||
|
||||
if( strcmp( name, "name" ) == 0 )
|
||||
attr = PyString_FromString( self->image->id.name + 2 );
|
||||
else if ( strcmp( name, "properties" ) == 0 )
|
||||
return BPy_Wrap_IDProperty( (ID*)self->image, IDP_GetProperties((ID*)self->image, 1) );
|
||||
else if( strcmp( name, "filename" ) == 0 )
|
||||
attr = PyString_FromString( self->image->name );
|
||||
else if( strcmp( name, "size" ) == 0 )
|
||||
|
@@ -81,6 +81,7 @@
|
||||
#include "Image.h"
|
||||
#include "Material.h"
|
||||
#include "Mathutils.h"
|
||||
#include "IDProp.h"
|
||||
#include "meshPrimitive.h"
|
||||
#include "constant.h"
|
||||
#include "gen_utils.h"
|
||||
@@ -7384,10 +7385,19 @@ 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) );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 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"},
|
||||
{"verts",
|
||||
(getter)Mesh_getVerts, (setter)Mesh_setVerts,
|
||||
"The mesh's vertices (MVert)",
|
||||
|
@@ -73,6 +73,7 @@
|
||||
#include "Object.h"
|
||||
#include "Key.h"
|
||||
#include "Mathutils.h"
|
||||
#include "IDProp.h"
|
||||
#include "constant.h"
|
||||
#include "gen_utils.h"
|
||||
|
||||
@@ -1718,6 +1719,9 @@ static PyObject *NMesh_getattr( PyObject * self, char *name )
|
||||
if( strcmp( name, "name" ) == 0 )
|
||||
return EXPP_incr_ret( me->name );
|
||||
|
||||
else if ( strcmp( name, "properties" ) == 0 )
|
||||
return BPy_Wrap_IDProperty( (ID*)me->mesh, IDP_GetProperties((ID*)me->mesh, 1) );
|
||||
|
||||
else if( strcmp( name, "mode" ) == 0 )
|
||||
return PyInt_FromLong( me->mode );
|
||||
|
||||
|
@@ -67,6 +67,7 @@ struct View3D;
|
||||
#include "Mesh.h"
|
||||
#include "Lattice.h"
|
||||
#include "Metaball.h"
|
||||
#include "IDProp.h"
|
||||
#include "Text3d.h"
|
||||
|
||||
#include "gen_utils.h"
|
||||
@@ -279,6 +280,10 @@ static PyObject *Scene_getAttr( BPy_Scene * self, char *name )
|
||||
|
||||
if( strcmp( name, "name" ) == 0 )
|
||||
attr = PyString_FromString( self->scene->id.name + 2 );
|
||||
|
||||
else if ( strcmp( name, "properties" ) == 0 )
|
||||
return BPy_Wrap_IDProperty( (ID*)self->scene, IDP_GetProperties((ID*)self->scene, 1) );
|
||||
|
||||
/* accept both Layer (for compatibility with ob.Layer) and Layers */
|
||||
else if( strncmp( name, "Layer", 5 ) == 0 )
|
||||
attr = PyInt_FromLong( self->scene->lay & (1<<20)-1 );
|
||||
|
Reference in New Issue
Block a user