diff --git a/source/blender/python/api2_2x/Pose.c b/source/blender/python/api2_2x/Pose.c index 4a168fbb862..6429696b864 100644 --- a/source/blender/python/api2_2x/Pose.c +++ b/source/blender/python/api2_2x/Pose.c @@ -54,6 +54,8 @@ #include "NLA.h" #include "gen_utils.h" +#include "DNA_armature_types.h" /*used for pose bone select*/ + extern void chan_calc_mat(bPoseChannel *chan); //------------------------ERROR CODES--------------------------------- @@ -908,6 +910,38 @@ static int PoseBone_setTail(BPy_PoseBone *self, PyObject *value, void *closure) return EXPP_intError(PyExc_AttributeError, "%s%s%s", sPoseBoneError, ".tail: ", "not able to set this property"); } +//------------------------PoseBone.sel (getter) +//Gets the pose bones selection +static PyObject *PoseBone_getSelect(BPy_PoseBone *self, void *closure) +{ + if (self->posechannel->bone->flag & BONE_SELECTED) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} +//------------------------PoseBone.sel (setter) +//Sets the pose bones selection +static int PoseBone_setSelect(BPy_PoseBone *self, PyObject *value, void *closure) +{ + if (PyObject_IsTrue( value )) + self->posechannel->bone->flag |= BONE_SELECTED; + else + self->posechannel->bone->flag &= ~(BONE_SELECTED | BONE_ACTIVE); + return 0; +} + + +//------------------------PoseBone.parent (getter) +//Gets the pose bones selection +static PyObject *PoseBone_getParent(BPy_PoseBone *self, void *closure) +{ + if (self->posechannel->parent) { + return PyPoseBone_FromPosechannel(self->posechannel->parent); + } else { + return EXPP_incr_ret(Py_None); + } +} + //------------------TYPE_OBECT IMPLEMENTATION--------------------------- //------------------------tp_getset //This contains methods for attributes that require checking @@ -928,12 +962,16 @@ static PyGetSetDef BPy_PoseBone_getset[] = { "The pose bone's head positon", NULL}, {"tail", (getter)PoseBone_getTail, (setter)PoseBone_setTail, "The pose bone's tail positon", NULL}, + {"sel", (getter)PoseBone_getSelect, (setter)PoseBone_setSelect, + "The pose selection state", NULL}, {"limitMin", (getter)PoseBone_getLimitMin, (setter)PoseBone_setLimitMin, "The pose bone dof min", NULL}, {"limitMax", (getter)PoseBone_getLimitMax, (setter)PoseBone_setLimitMax, "The pose bone dof max", NULL}, {"constraints", (getter)PoseBone_getConstraints, (setter)NULL, "The list of contraints that pertain to this pose bone", NULL}, + {"parent", (getter)PoseBone_getParent, (setter)NULL, + "The bones parent (read only for posebones)", NULL}, {NULL, NULL, NULL, NULL, NULL} }; //------------------------tp_dealloc diff --git a/source/blender/python/api2_2x/Pose.h b/source/blender/python/api2_2x/Pose.h index 0eb046c94cd..d4df65042e8 100644 --- a/source/blender/python/api2_2x/Pose.h +++ b/source/blender/python/api2_2x/Pose.h @@ -46,7 +46,7 @@ extern PyTypeObject PoseBonesDict_Type; //-------------------STRUCT DEFINITION---------------------------- typedef struct { PyObject_HEAD - PyObject *bonesMap; + PyObject *bonesMap; ListBase *bones; } BPy_PoseBonesDict; @@ -60,6 +60,7 @@ typedef struct { typedef struct { PyObject_HEAD bPoseChannel *posechannel; + } BPy_PoseBone; //-------------------VISIBLE PROTOTYPES------------------------- diff --git a/source/blender/python/api2_2x/doc/Pose.py b/source/blender/python/api2_2x/doc/Pose.py index ca3c293e485..9e06e614666 100644 --- a/source/blender/python/api2_2x/doc/Pose.py +++ b/source/blender/python/api2_2x/doc/Pose.py @@ -81,6 +81,10 @@ class PoseBone: @type head: Vector object @ivar tail: The final tail location for this PoseBone. (not settable) @type tail: Vector object + @ivar sel: The selection state of this bone + @type sel: Boolean + @ivar parent: The parent of this posebone (not settable) + @type parent: posebone or None @ivar localMatrix: The matrix combination of rot/quat/loc. @type localMatrix: Matrix object @ivar poseMatrix: The total transformation of this PoseBone including constraints.