Hi! Currently in my rigs I use drivers to move bones from layer to layer, based on the slider of a custom property.
In other words, this is an auto-hiding feature for IK/Fk. So, dependeing on the state of the IK/FK slider, certaint bones appear or dissapear from certain layers.
So, to make this work, I just add these drivers to the layer properties of each bone. But well, this has several fallbacks, as poor performance (as this kind of driver updates are a killer), and blender saying that this driver causes a cyclic dependency when I link the rig.
Therefore, I’d like to do this bone hiding with python, but… My python knowledge is not so cool, hehe.
So, for example, here I have an operator :
class Operator_Torso_HIDE(bpy.types.Operator):
bl_idname = "torso_hide"
bl_label = "BlenRig Torso HIDE"
def execute(self, context):
arm_data = bpy.context.active_object.data
ob = bpy.context.active_object
cust_prop = ob.items()
for prop in cust_prop:
if prop[0] == 'ik_torso' and prop[1] == 0.0:
arm_data.bones['torso_ctrl'].layers[0] = True
elif prop[0] == 'ik_torso' and prop[1] == 1.0:
arm_data.bones['torso_ctrl'].layers[0] = False
So, when I call this operator, the custom property called ‘ik_torso’ gets evaluated and then it hides or unhides the torso controler bone, by moving in or out of layer 0.
Now, what I want to do is not using an operator, but somehow evaluate the ‘ik_torso’ property when it is changed, so that depending on the result, the torso controler is displayed or not. That’s what I guess the update funtion is used for, but I really don’t know how to implement it.
If you want to help me with this, I’d really appreciate that you copy full scripts, not part of scripts, as I may be too noobie to make it work if I only get pieces of code!
Thanks!