This code is an example of how to do that, but I've left out three settings because I didn't know if the default was enough
import bpy
src = bpy.data.objects['src']
dst = bpy.data.objects['dst']
for bone in dst.pose.bones:
bone.constraints.new('COPY_TRANSFORMS')
constraint = bone.constraints[-1]
constraint.target = src
constraint.subtarget = bone.name
You need to change the first two statements after the import
to whatever code you need to select the two armatures. I tested with two armatures that had obvious names.
I didn't set the Mix, Target Space, Owner Space, or influence, assuming the defaults were what you wanted. They are the following fields mix_mode
, target_space
, owner_space
, and influence
.
mix mode can take any value in this list: 'REPLACE', 'BEFORE_FULL', 'BEFORE', 'BEFORE_SPLIT', 'AFTER_FULL', 'AFTER', 'AFTER_SPLIT'.
The spaces can take any value in this list: 'WORLD', 'CUSTOM', 'POSE', 'LOCAL_WITH_PARENT', 'LOCAL', 'LOCAL_OWNER_ORIENT'
Influence is a floating point number in the range of 0.0 to 1.0
You can find out more about the meaning of the values in the Copy Transforms Constraint manual page.