1
$\begingroup$

I'm just beginning to get into drivers and custom properties for bones and I was wondering if its possible to set up drivers or custom properties for buttons rather than sliders. The reason is I have a face rig with tons of "stretch to" bones and every time I edit any bones I have to manually go through and hit the "reset" button in each bones' individual constraint menu. What I'd like to set up is a driver or custom property so that I can hit one button to reset all the stretch to bones at once.

$\endgroup$
2
+50
$\begingroup$

Not sure drivers and custom properties are a good solution for that.

Lucky for you, I have run across similar strugglers these years when rigging and collected some python scripts which you can run to fix all that. Simply copy-paste them into the text editor, and click the run button when you need them. You have to be in Pose mode though.

First one : reset every "stretch to" constraints of an armature :

import bpy

for b in bpy.context.selected_pose_bones:
    for c in b.constraints:
        if c.name == "Stretch To":
            c.rest_length = 0

Second one, same use as the previous, but to set inverse of every "child of" constraints of the armature :

import bpy

ob = bpy.context.active_object

# Take a copy of current layers
org_layers = ob.data.layers[:]

# Show all layers
for i in range(len(org_layers)):
    ob.data.layers[i] = True

for b in ob.pose.bones:
    for c in b.constraints:
        if c.type == "CHILD_OF":
            context_py = bpy.context.copy()
            context_py["constraint"] = c
            ob.data.bones.active = b.bone
            bpy.ops.constraint.childof_set_inverse(context_py, constraint="Child Of", owner='BONE')

# Reset back to orginal layer state
for i in range(len(org_layers)):
    ob.data.layers[i] = org_layers[i]

I'll be working on making those scripts more easy to use, as add-ons with accessible buttons right in the viewport's UI. You can follow the advancements on my github.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.