Hi there !
A few years ago I used to be using a little script found here in order to reset every “Stretch to” constraints of an armature, even on unselected/offlayered bones :
import bpy for b in bpy.context.active_object.pose.bones: for c in b.constraints: if c.type == "STRETCH_TO": c.rest_length = 0
It has been very useful, especially when you drastically edit the bones positions of an already finished rig (i.e. when you reuse the same rig for similar but different models).
I would like a very similar script, but with “set inverse” for CHILD_OF constraint.
But I barely know Blender’s API and every try haven’t got anything working nor going the right direction.
My last attempt looked like that:
import bpy for b in bpy.context.active_object.pose.bones: for c in b.constraints: if c.type == "CHILD_OF": context_py = bpy.context.copy() context_py["constraint"] = constraint bpy.ops.constraint.childof_set_inverse(context_py, constraint="Child Of")
And got this error:
Traceback (most recent call last): File "\Text", line 7, in <module> NameError: name 'constraint' is not defined
If someone could help me, that would be kind.