Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/python/api2_2x/Armature.c27
-rwxr-xr-xsource/blender/python/api2_2x/Group.c21
-rw-r--r--source/blender/python/api2_2x/Material.c21
-rw-r--r--source/blender/python/api2_2x/Mesh.c21
-rw-r--r--source/blender/python/api2_2x/Metaball.c19
-rw-r--r--source/blender/python/api2_2x/Object.c21
-rw-r--r--source/blender/python/api2_2x/doc/Armature.py5
-rw-r--r--source/blender/python/api2_2x/doc/Group.py9
-rw-r--r--source/blender/python/api2_2x/doc/Metaball.py3
-rw-r--r--source/blender/python/api2_2x/gen_utils.c28
-rw-r--r--source/blender/python/api2_2x/gen_utils.h2
11 files changed, 113 insertions, 64 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index fb8200c6c8e..38109cdce5b 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -607,6 +607,29 @@ AttributeError:
return EXPP_ReturnIntError( PyExc_TypeError,
"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)
{
@@ -1001,6 +1024,10 @@ 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
diff --git a/source/blender/python/api2_2x/Group.c b/source/blender/python/api2_2x/Group.c
index f9e01b85f04..c3806f32091 100755
--- a/source/blender/python/api2_2x/Group.c
+++ b/source/blender/python/api2_2x/Group.c
@@ -250,13 +250,24 @@ static PyObject *Group_getName( BPy_Group * self, PyObject * args )
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_PY(self);
+ return SetIdFakeUser(&self->group->id, value);
+}
@@ -302,6 +313,10 @@ static PyGetSetDef BPy_Group_getseters[] = {
(getter)Group_getUsers, (setter)NULL,
"Number of group users",
NULL},
+ {"fakeUser",
+ (getter)Group_getFakeUser, (setter)Group_setFakeUser,
+ "Number of group users",
+ NULL},
{"layers",
(getter)Group_getLayers, (setter)Group_setLayers,
"Number of group users",
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index d52f5caf949..38855c167e9 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -2869,26 +2869,7 @@ static PyObject *Material_getFakeUser( BPy_Material * self )
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;
+ return SetIdFakeUser(&self->material->id, value);
}
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c
index a687dfda1d6..45c599872f0 100644
--- a/source/blender/python/api2_2x/Mesh.c
+++ b/source/blender/python/api2_2x/Mesh.c
@@ -6954,26 +6954,7 @@ 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) {
- 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;
+ return SetIdFakeUser(&self->mesh->id, value);
}
static PyObject *Mesh_getFlag( BPy_Mesh * self, void *type )
diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c
index ca4f61e8878..bfa985ea133 100644
--- a/source/blender/python/api2_2x/Metaball.c
+++ b/source/blender/python/api2_2x/Metaball.c
@@ -118,6 +118,8 @@ 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: */
@@ -178,6 +180,10 @@ static PyGetSetDef BPy_Metaball_getseters[] = {
(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},
{"materials",
(getter)Metaball_getMaterials, (setter)Metaball_setMaterials,
"Number of metaball users",
@@ -698,6 +704,19 @@ 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 )
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 01bc08436e6..fbd13b653fe 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -4456,26 +4456,7 @@ static PyObject *Object_getFakeUser( BPy_Object * self )
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;
+ return SetIdFakeUser(&self->object->id, value);
}
/* Localspace matrix */
diff --git a/source/blender/python/api2_2x/doc/Armature.py b/source/blender/python/api2_2x/doc/Armature.py
index 791d18e2566..887b273456a 100644
--- a/source/blender/python/api2_2x/doc/Armature.py
+++ b/source/blender/python/api2_2x/doc/Armature.py
@@ -161,6 +161,11 @@ class Armature:
@type mirrorEdit: Bool
@ivar autoIK: Adds temporary IK chains while grabbing bones
@type autoIK: Bool
+ @ivar users: The number of users of the armature. 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
"""
def __init__(name = 'myArmature'):
diff --git a/source/blender/python/api2_2x/doc/Group.py b/source/blender/python/api2_2x/doc/Group.py
index c05d62774a1..4f3f5ba439b 100644
--- a/source/blender/python/api2_2x/doc/Group.py
+++ b/source/blender/python/api2_2x/doc/Group.py
@@ -88,11 +88,18 @@ class Group:
================
This object gives access to Groups in Blender.
@ivar name: The name of this Group object.
+ @type name: string
@ivar users: Number of users this group has (read only)
- @ivar layers: Layer mask for this group.
+ @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 layers: Layer bitmask for this group.
+ @type layers: int
@ivar objects: Objects that this group uses.
This is a sequence with-list like access so use list(grp.objects) if you need to use a list (where grp is a group).
The groups objects can be set by assigning a list or iterator of objects to the groups objects.
objects.link() and objects.unlink() also work with the the objects iterator just like with lists.
+ @type objects: custom object sequence
"""
diff --git a/source/blender/python/api2_2x/doc/Metaball.py b/source/blender/python/api2_2x/doc/Metaball.py
index 424f0541624..2fb908e90e0 100644
--- a/source/blender/python/api2_2x/doc/Metaball.py
+++ b/source/blender/python/api2_2x/doc/Metaball.py
@@ -131,6 +131,9 @@ class Metaball:
@type name: string
@ivar users: The user count (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 elements: Element iterator of MetaElemSeq type.
@type elements: MetaElemSeq
@ivar wiresize: display resolution.
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c
index 23128f94805..4bd079f2b82 100644
--- a/source/blender/python/api2_2x/gen_utils.c
+++ b/source/blender/python/api2_2x/gen_utils.c
@@ -159,6 +159,34 @@ ID *GetIdFromList( ListBase * list, char *name )
}
/*****************************************************************************/
+/* Description: This function sets the fake user status of the ID */
+/* returns an int error, so from getsetattrs */
+/*****************************************************************************/
+int SetIdFakeUser( ID * id, PyObject *value)
+{
+ int param;
+ 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;
+}
+
+
+
+/*****************************************************************************/
/* Description: These functions set an internal string with the given type */
/* and error_msg arguments. */
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/gen_utils.h b/source/blender/python/api2_2x/gen_utils.h
index b9400267ca5..04eddebddc1 100644
--- a/source/blender/python/api2_2x/gen_utils.h
+++ b/source/blender/python/api2_2x/gen_utils.h
@@ -66,6 +66,8 @@ PyObject *EXPP_GetModuleConstant(char *module, char *constant);
int StringEqual( const char *string1, const char *string2 );
char *GetIdName( ID * id );
+int SetIdFakeUser( ID * id, PyObject *value);
+
ID *GetIdFromList( ListBase * list, char *name );
PyObject *PythonReturnErrorObject( PyObject * type, char *error_msg );