From 85d75077a6f21e175689ae0317d5847e321a43c4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 Aug 2009 22:11:33 +0000 Subject: [PATCH] [#19035] New Python command to set the active flag of Armature Bones from Ivo Grigull (loolarge) Removed redraw calls from the python function, added epydocs. --- source/blender/python/api2_2x/Bone.c | 22 +++++++++++++++++++ source/blender/python/api2_2x/doc/Armature.py | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c index cacb3584344..f042176ec59 100644 --- a/source/blender/python/api2_2x/Bone.c +++ b/source/blender/python/api2_2x/Bone.c @@ -1273,6 +1273,26 @@ static int Bone_setLayerMask(BPy_Bone *self, PyObject *value) return 0; } +//-------------------------Bone.activate() +static PyObject *Bone_activate(BPy_Bone *self) + +{ + struct Bone *firstbone = self->bone; // unset all bone's active flag first + while(firstbone->prev ) + firstbone= firstbone->prev; + + while(firstbone->next) { + firstbone->flag &= ~BONE_ACTIVE; + firstbone= firstbone->next; + } + + self->bone->flag |= BONE_ACTIVE; // this makes the bones curves display in the IPO editor + + /* redraw will need to be called by python */ + + Py_RETURN_NONE; + +} //------------------TYPE_OBECT IMPLEMENTATION-------------------------- //------------------------tp_methods @@ -1284,6 +1304,8 @@ static PyMethodDef BPy_Bone_methods[] = { "() - True/False - Bone has 1 or more children"}, {"getAllChildren", (PyCFunction) Bone_getAllChildren, METH_NOARGS, "() - All the children for this bone - including children's children"}, + {"activate", (PyCFunction) Bone_activate, METH_NOARGS, + "Display curves in the IPO editor"}, {NULL, NULL, 0, NULL} }; //------------------------tp_getset diff --git a/source/blender/python/api2_2x/doc/Armature.py b/source/blender/python/api2_2x/doc/Armature.py index 9aceb0105e3..78b9214f121 100644 --- a/source/blender/python/api2_2x/doc/Armature.py +++ b/source/blender/python/api2_2x/doc/Armature.py @@ -307,6 +307,11 @@ class Bone: @type layerMask: Int """ + def activate(): + """ + Sets this bone as active, de-activating all others. + """ + def hasParent(): """ Whether or not this bone has a parent