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:
authorCampbell Barton <ideasman42@gmail.com>2007-10-26 12:19:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-10-26 12:19:40 +0400
commitef85f6ea21c0af43b96c6c3cbb1b80f23ac00266 (patch)
treeeaf81dc5f7de1cc20c7a38e2b48c919ad7744612 /source/blender/python/api2_2x/Armature.c
parentfd98d38672ba4339e9ebb31d5d54e40e3dde045a (diff)
==Python API==
layerMask access for bone and armatures Window.PoseMode() similar to Window.EditMode()
Diffstat (limited to 'source/blender/python/api2_2x/Armature.c')
-rw-r--r--source/blender/python/api2_2x/Armature.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index 1ad5938c17e..47ee2564698 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -297,9 +297,7 @@ static int BonesDict_SetItem(BPy_BonesDict *self, PyObject *key, PyObject *value
editbone->zwidth = ((BPy_EditBone*)value)->zwidth;
VECCOPY(editbone->head, ((BPy_EditBone*)value)->head);
VECCOPY(editbone->tail, ((BPy_EditBone*)value)->tail);
-
- // FIXME, should be exposed via python. this avoids creating bones with no layers.
- editbone->layer= 1;
+ editbone->layer= ((BPy_EditBone*)value)->layer;
//set object pointer
((BPy_EditBone*)value)->editbone = editbone;
@@ -927,6 +925,36 @@ AttributeError:
return EXPP_intError(PyExc_AttributeError, "%s%s",
sArmatureError, "You are not allowed to change the .Bones attribute");
}
+
+//------------------------Bone.layerMask (get)
+static PyObject *Armature_getLayerMask(BPy_Armature *self)
+{
+ /* do this extra stuff because the short's bits can be negative values */
+ unsigned short laymask = 0;
+ laymask |= self->armature->layer;
+ return PyInt_FromLong((int)laymask);
+}
+//------------------------Bone.layerMask (set)
+static int Armature_setLayerMask(BPy_Armature *self, PyObject *value)
+{
+ int laymask;
+ if (!PyInt_Check(value)) {
+ return EXPP_ReturnIntError( PyExc_AttributeError,
+ "expected an integer (bitmask) as argument" );
+ }
+
+ laymask = PyInt_AsLong(value);
+
+ if (laymask <= 0 || laymask > (1<<16) - 1)
+ return EXPP_ReturnIntError( PyExc_AttributeError,
+ "bitmask must have from 1 up to 16 bits set");
+
+ self->armature->layer = 0;
+ self->armature->layer |= laymask;
+
+ return 0;
+}
+
//------------------TYPE_OBECT IMPLEMENTATION--------------------------
//------------------------tp_doc
//The __doc__ string for this object
@@ -974,6 +1002,8 @@ 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},
+ {"layerMask", (getter)Armature_getLayerMask, (setter)Armature_setLayerMask,
+ "Layer bitmask", NULL },
{NULL, NULL, NULL, NULL, NULL}
};
//------------------------tp_new