# Copy bone transform question

What i'm trying to do is to duplicate whole armature and add Copy Transform to each bone on duplicate. Basically i want arm from armature duplicate to have Copy Transform constraint with target on arm from original armature.

Now this isnt hard to do. You just make duplicate, select armature copy,fire up pose mode and then go from bone to bone and add Copy Transform constraint.

Unfortunately armature is kinda complicated and have around 80 bones which makes this process rather long and tedious. I'm kinda noob when it comes to scripting so is there any faster way to achieve this? Some sort of magic or am i asking for a miracle?

• I am assuming the bones are named the same? – Leander May 6 '20 at 19:16
• – batFINGER May 6 '20 at 20:21

You will require two armature, one to copy the transformations from and one to copy the transformations to. I have named my armature respectively Armature1 and Armature2.

We can access them through the objects collection inbpy.data.

armatureFrom = bpy.data.objects['Armature1']
armatureTo = bpy.data.objects['Armature2']


Looping through lists or collections in python is done with a for loop. The pose bones (which can have constraints are fields of the armature's pose property.

for boneTo in armatureTo.pose.bones:


We can check for a corresponding bone in the armatureFrom with the Blender API's get() method, which works on all blender collections.

boneFrom = armatureFrom.pose.bones.get(boneTo.name)
if boneFrom == None:
continue


If you want to remove all constraints from the target bone you can loop through them and remove them with the remove() method.

for con in boneTo.constraints:
boneTo.constraints.remove(con)


By hovering your mouse over Blender properties you can get their python tooltips. I did so with an existing copy transforms constraint and could find the names of the fields which we need to assign.

copy_con = boneTo.constraints.new('COPY_TRANSFORMS')
copy_con.target = armatureFrom
copy_con.subtarget = boneFrom.name
copy_con.target_space = 'POSE'
copy_con.owner_space = 'POSE'


The completed script is here. Paste it in a text editor area in Blender and press Run Script to run it. Make sure you replace the names of the armatures with the names of armatures present in your file. Also backup your work. There are some destructive thing going on, like removing all constraints.

import bpy

armatureFrom = bpy.data.objects['Armature1']
armatureTo = bpy.data.objects['Armature2']

for boneTo in armatureTo.pose.bones:
boneFrom = armatureFrom.pose.bones.get(boneTo.name)
if boneFrom == None:
continue

for con in boneTo.constraints:
boneTo.constraints.remove(con)

copy_con = boneTo.constraints.new('COPY_TRANSFORMS')
copy_con.target = armatureFrom
copy_con.subtarget = boneFrom.name
copy_con.target_space = 'POSE'
copy_con.owner_space = 'POSE'

• Now this is complete answer that i was looking for ,even explained in details so that even i can understand it. Big thanks! – domi May 7 '20 at 20:37