Enable/Disable DupFaces from the Python API.
Fixed a (own) bug in fakeUsers and added fakeUsers to Objects and Materials as well as Mesh.
This commit is contained in:
@@ -527,12 +527,14 @@ 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_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 );*/
|
||||
|
||||
@@ -1086,6 +1088,10 @@ static PyGetSetDef BPy_Material_getseters[] = {
|
||||
(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},
|
||||
{"properties", (getter) Material_getProperties, (setter)NULL,
|
||||
"Get material's ID properties"},
|
||||
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
|
||||
@@ -2853,6 +2859,39 @@ 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 )
|
||||
{
|
||||
int param;
|
||||
ID *id = &self->material->id;
|
||||
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--;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* #####DEPRECATED###### */
|
||||
|
||||
static PyObject *Matr_oldsetAdd( BPy_Material * self, PyObject * args )
|
||||
|
||||
@@ -6840,18 +6840,23 @@ static PyObject *Mesh_getFakeUser( BPy_Mesh * self )
|
||||
static int Mesh_setFakeUser( BPy_Mesh * self, PyObject * value )
|
||||
{
|
||||
int param;
|
||||
|
||||
ID *id = &self->mesh->id;
|
||||
param = PyObject_IsTrue( value );
|
||||
|
||||
if( param == -1 )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected int argument in range [0,1]" );
|
||||
|
||||
if (param) {
|
||||
self->mesh->id.flag |= LIB_FAKEUSER;
|
||||
self->mesh->id.us++;
|
||||
if (!(id->flag & LIB_FAKEUSER)) {
|
||||
id->flag |= LIB_FAKEUSER;
|
||||
id_us_plus(id);
|
||||
}
|
||||
} else {
|
||||
self->mesh->id.flag &= ~LIB_FAKEUSER;
|
||||
self->mesh->id.us--;
|
||||
if (id->flag & LIB_FAKEUSER) {
|
||||
id->flag &= ~LIB_FAKEUSER;
|
||||
id->us--;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4422,6 +4422,38 @@ 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 )
|
||||
{
|
||||
int param;
|
||||
ID *id = &self->object->id;
|
||||
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--;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Localspace matrix */
|
||||
|
||||
static PyObject *Object_getMatrixLocal( BPy_Object * self )
|
||||
@@ -4867,6 +4899,10 @@ static PyGetSetDef BPy_Object_getseters[] = {
|
||||
(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,
|
||||
@@ -5008,14 +5044,23 @@ static PyGetSetDef BPy_Object_getseters[] = {
|
||||
"Transparent materials for the active object (mesh only) enabled",
|
||||
(void *)OB_DRAWTRANSP},
|
||||
|
||||
{"enableDupVerts",
|
||||
(getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
|
||||
"Duplicate child objects on all vertices",
|
||||
(void *)OB_DUPLIVERTS},
|
||||
{"enableNLAOverride",
|
||||
(getter)Object_getNLAflagBits, (setter)Object_setNLAflagBits,
|
||||
"Toggles Action-NLA based animation",
|
||||
(void *)OB_NLA_OVERRIDE},
|
||||
|
||||
{"enableDupVerts",
|
||||
(getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
|
||||
"Duplicate child objects on all vertices",
|
||||
(void *)OB_DUPLIVERTS},
|
||||
{"enableDupFaces",
|
||||
(getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
|
||||
"Duplicate child objects on all faces",
|
||||
(void *)OB_DUPLIFACES},
|
||||
{"enableDupFacesScale",
|
||||
(getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
|
||||
"Use face scale to scale all dupliFaces",
|
||||
(void *)OB_DUPLIFACES_SCALE},
|
||||
{"enableDupFrames",
|
||||
(getter)Object_getTransflagBits, (setter)Object_setTransflagBits,
|
||||
"Make copy of object for every frame",
|
||||
|
||||
@@ -285,6 +285,9 @@ class Material:
|
||||
@type translucency: float
|
||||
@ivar users: Number of material users.
|
||||
@type users: int
|
||||
@ivar fakeUser: The fake user status.
|
||||
enabling this will keep it in the blend even if there are no users.
|
||||
@type fakeUser: bool
|
||||
@ivar zOffset: Artificial offset in the Z buffer (for Ztransp option).
|
||||
Value is clamped to the range [0.0,10.0].
|
||||
@type zOffset: float
|
||||
|
||||
@@ -722,6 +722,9 @@ class Mesh:
|
||||
@type subDivLevels: list of 2 ints
|
||||
@ivar users: The number of Objects using (linked to) this mesh. (read only)
|
||||
@type users: int
|
||||
@ivar fakeUser: The fake user status.
|
||||
enabling this will keep it in the blend even if there are no users.
|
||||
@type fakeUser: bool
|
||||
|
||||
@ivar faceUV: The mesh contains UV-mapped textured faces. Enabling faceUV
|
||||
does not initialize the face colors like the Blender UI does; this must
|
||||
|
||||
@@ -407,6 +407,12 @@ class Object:
|
||||
Does not indicate that this object has any dupliVerts,
|
||||
(as returned by L{DupObjects}) just that dupliVerts are enabled.
|
||||
@type enableDupVerts: boolean
|
||||
@ivar enableDupFaces: The DupliFaces status of the object.
|
||||
Does not indicate that this object has any dupliFaces,
|
||||
(as returned by L{DupObjects}) just that dupliFaces are enabled.
|
||||
@type enableDupFaces: boolean
|
||||
@ivar enableDupFacesScale: The DupliFacesScale status of the object.
|
||||
@type enableDupFacesScale: boolean
|
||||
@ivar enableDupFrames: The DupliFrames status of the object.
|
||||
Does not indicate that this object has any dupliFrames,
|
||||
(as returned by L{DupObjects}) just that dupliFrames are enabled.
|
||||
@@ -472,6 +478,9 @@ class Object:
|
||||
@type type: string
|
||||
@ivar users: The number of users of the object. Read-only.
|
||||
@type users: int
|
||||
@ivar fakeUser: The fake user status.
|
||||
enabling this will keep it in the blend even if there are no users.
|
||||
@type fakeUser: bool
|
||||
@ivar boundingBox: The bounding box of this object. Read-only.
|
||||
@type boundingBox: list of 8 3D vectors
|
||||
@ivar drawType: The object's drawing type.
|
||||
|
||||
Reference in New Issue
Block a user