Hi all,
I’m trying to reset all the Stretch To constraints in the selected rig via a python script.
So far I’ve tried this:
import bpy
for bone in bpy.context.selected_pose_bones:
override = bpy.context.copy(bone)
bpy.ops.constraint.stretchto_reset(override, constraint=“Stretch To”, owner=‘BONE’)
which returns the following error:
Traceback (most recent call last):
File “/media/data/glass_half/pre/test_rigs/flexirig-stretchto_fix.blend/Text”, line 5, in <module>
TypeError: copy() takes 1 positional argument but 2 were given
The problem seems to be how I’m using context copy. Any suggestions how I could get this working?
context.copy() does not take any arguments. You can only copy the entire context to a new dict.
If you need to change anything of that context, do it after the copying:
override[“foo”] = “bar”
I wonder if you really need the strechto_reset() operator. It’s often possible to do such things with RNA methods.