diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-10-27 02:38:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-10-27 02:38:15 +0400 |
commit | 0e94605a9084f3f1d97d739f4dc8e42d24f5e9c5 (patch) | |
tree | c6867a5322599689e57c1ddf39da89b5dbe5fb71 | |
parent | ddb8120e03e83b1d45e7e69869a55134dc0060fa (diff) |
==Python API==
layerMask access for pose bones, even though this is a Bone property, its much more convenient to add access from the poseBone, it also matches how the
user interface works.
-rw-r--r-- | source/blender/python/api2_2x/Pose.c | 31 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Pose.py | 6 |
2 files changed, 35 insertions, 2 deletions
diff --git a/source/blender/python/api2_2x/Pose.c b/source/blender/python/api2_2x/Pose.c index a67edd5dff4..01fbe591a74 100644 --- a/source/blender/python/api2_2x/Pose.c +++ b/source/blender/python/api2_2x/Pose.c @@ -1128,6 +1128,34 @@ static int PoseBone_setIKFlag(BPy_PoseBone *self, PyObject *value, void *flag) return 0; } +//------------------------Bone.layerMask (get) +static PyObject *PoseBone_getLayerMask(BPy_PoseBone *self) +{ + /* do this extra stuff because the short's bits can be negative values */ + unsigned short laymask = 0; + laymask |= self->posechannel->bone->layer; + return PyInt_FromLong((int)laymask); +} +//------------------------Bone.layerMask (set) +static int PoseBone_setLayerMask(BPy_PoseBone *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->posechannel->bone->layer = 0; + self->posechannel->bone->layer |= laymask; + + return 0; +} //------------------TYPE_OBECT IMPLEMENTATION--------------------------- //------------------------tp_getset @@ -1188,7 +1216,8 @@ static PyGetSetDef BPy_PoseBone_getset[] = { "disable Y DoF when part of an IK", (void *)BONE_IK_NO_YDOF }, {"lockZRot", (getter)PoseBone_getIKFlag, (setter)PoseBone_setIKFlag, "disable Z DoF when part of an IK", (void *)BONE_IK_NO_ZDOF }, - + {"layerMask", (getter)PoseBone_getLayerMask, (setter)PoseBone_setLayerMask, + "Layer bitmask", NULL }, {NULL, NULL, NULL, NULL, NULL} }; //------------------------tp_dealloc diff --git a/source/blender/python/api2_2x/doc/Pose.py b/source/blender/python/api2_2x/doc/Pose.py index e0c0c241044..ad1b44da5e2 100644 --- a/source/blender/python/api2_2x/doc/Pose.py +++ b/source/blender/python/api2_2x/doc/Pose.py @@ -217,7 +217,11 @@ class PoseBone: @ivar lockYRot: Disable Y DoF when part of an IK. @type lockZRot: bool @ivar lockZRot: Disable Z DoF when part of an IK. - + @ivar layerMask: Layer bitmask + Example:: + # set bone to layers 14 and 16 + bone.layerMask = (1<<13) + (1<<15) + @type layerMask: Int """ def insertKey(parentObject, frameNumber, type = "[Pose.LOC, Pose.ROT, Pose.SIZE]", fast = False): |