Added group.layers bitfield to the python API

This commit is contained in:
Campbell Barton 2006-11-16 21:38:08 +00:00
parent 1a36a9080c
commit 97d306e68f
2 changed files with 42 additions and 1 deletions

@ -253,6 +253,43 @@ static PyObject *Group_getUsers( BPy_Group * self )
return PyInt_FromLong( self->group->id.us );
}
/*****************************************************************************/
/* Python BPy_Group methods: */
/*****************************************************************************/
static int Group_setLayers( BPy_Group * self, PyObject * value )
{
unsigned int laymask = 0;
GROUP_DEL_CHECK_INT(self);
if( !PyInt_CheckExact( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected an integer (bitmask) as argument" );
laymask = ( unsigned int )PyInt_AS_LONG( value );
if( laymask <= 0 )
return EXPP_ReturnIntError( PyExc_ValueError,
"layer value cannot be zero or below" );
self->group->layer= laymask & ((1<<20) - 1);
return 0;
}
static PyObject *Group_getLayers( BPy_Group * self )
{
return PyInt_FromLong( self->group->layer );
}
/*****************************************************************************/
/* Python attributes get/set structure: */
/*****************************************************************************/
@ -265,6 +302,10 @@ static PyGetSetDef BPy_Group_getseters[] = {
(getter)Group_getUsers, (setter)NULL,
"Number of group users",
NULL},
{"layers",
(getter)Group_getLayers, (setter)Group_setLayers,
"Number of group users",
NULL},
{"objects",
(getter)Group_getObjects, (setter)Group_setObjects,
"objects in this group",
@ -728,7 +769,6 @@ static PyObject *GroupObSeq_add( BPy_GroupObSeq * self, PyObject *args )
{
PyObject *pyobj;
Object *blen_ob;
Base *base= NULL;
GROUP_DEL_CHECK_PY(self->bpygroup);

@ -92,6 +92,7 @@ class Group:
This object gives access to Groups in Blender.
@ivar name: The name of this Group object.
@ivar users: Number of users this group has (read only)
@ivar layers: Layer mask for this group.
@ivar objects: Objects that this group uses.
This is an iterator with list like access so use list(gp.objects) if you need to use a list. (where gp is a group object).
The groups objects can be set by assigning a list or iterator of objects to the groups objects.