I am trying to apply Set Inverse on all the ChildOf Constraints on the armature, using animation nodes Script Node in blender 2.82. But when triggering the script I get only this error:
How can I fix that issue?
import bpy
if inverse:
oby = bpy.data.objects['metarig2']
bpy.context.view_layer.objects.active = oby
pbones = bpy.data.objects['metarig2'].pose.bones
for pbone in pbones:
isConstraint = False
if len(pbone.constraints)>0:
for const in pbone.constraints:
if const.type == "CHILD_OF":
context_copy = bpy.context.copy()
context_copy["constraint"] = pbone.constraints["Child Of"]
#bpy.data.objects['metarig2'].data.bones.active = pbone.bone
bname = pbone.bone.name
bpy.data.objects['metarig2'].data.bones.active = bpy.data.objects['metarig2'].data.bones[bname]
bpy.ops.constraint.childof_set_inverse(context_copy, constraint="Child Of", owner='BONE')
bpy.data.objects['metarig2'].select = False
activ = bpy.data.objects['metarig']
bpy.context.scene.objects.active = activ