# Mirroring / Copying Constraints over a whole rig

Is there a "Mirror Constraint Tool" in Blender, Much Like there is a "Mirror Armature Tool" in Blender's --> Armature -> Editmode? I found the "Copy Constraint" Tool/function But NO "Paste Constraint" Tool/function. And from the methods I've seen online this has to be solved one bone at a time, even with the Copy Constraint Tool used properly.

My .blend file can be found here:

To use the Copy Constraint, you select an object then add a Copy Constraint, then select which other object you want to copy the property from (location, rotation). So no need for paste constraint. For mirroring the armature, you will find x-mirror property in the tools menu in the edit mode of the armature. Just replace the name of the Armature with the name of your Armature.

UPDATE:

To do what you want it will be easier to use python. I wrote a script that copies constraint from bones with ".L" to corresponding bones with ".R"

import bpy
context = bpy.context
scene = context.scene
MyArmature = bpy.data.objects["Armature"]
bpy.ops.object.select_all(action='DESELECT')
MyArmature.select = True
bpy.context.scene.objects.active = MyArmature
bpy.ops.object.posemode_toggle()
bpy.ops.pose.select_all(action='SELECT')
all_bones = bpy.context.selected_pose_bones
for bone in all_bones:
bpy.ops.pose.select_all(action='DESELECT')
if ".L" in bone.name:
boneL = MyArmature.data.bones[bone.name]
boneR = MyArmature.data.bones[bone.name.replace('.L','.R')]
boneR.select = True
boneL.select = True
MyArmature.data.bones.active = boneL
if len(MyArmature.pose.bones[boneL.name].constraints) !=0:
bpy.ops.object.constraints_copy()
bpy.ops.pose.constraints_copy()
for con in MyArmature.pose.bones[boneR.name].constraints:
con.subtarget = con.subtarget.replace('.L','.R')


This is how it looks before running the script:

And This is how it looks after running the script where the constraints are copied:

Updated .blend file can be found here:

• To add to Tak's answer adding a if hasattr statement before the last statement will allow his code to work if there are constraints that don't have subtargets, such as a limit location constraint. Here's the line: if hasattr(con, 'subtarget'): – Skyler Jyvqh Jul 26 '18 at 2:22
• If you want to ignore KinematicConstraint and TransformConstraint because the code does not mirror the Pole Angle ect correctly. Just put this: if "CopyRotationConstraint" in str(MyArmature.pose.bones[boneL.name].constraints[0]):#Type of constraint to copy. After this: if len(MyArmature.pose.bones[boneL.name].constraints) !=0: you could also: if "KinematicConstraint" not in str(MyArmature.pose.bones[boneL.name].constraints[0]):#Type of constraint to skip – ProllySomethingDumb Nov 29 '18 at 12:59

With less Python than the other answer:

1. From the Armature's Edit Mode, select the bones you'd like to copy to the other side.

2. Run "Armature" > "Symmetrize". This will copy all the bone settings, including constraints— But it will not always replace the constraints' targets with the mirrored equivalents.

3. Open a Python Console UI area.

4. From the armature's Pose Mode, Select the newly mirrored bones, and use a one-liner like below to replace the constraints' targets with the mirrored equivalents:
[setattr(c, 'subtarget', c.subtarget.replace('.L', '.R')) for b in C.selected_pose_bones for c in b.constraints if hasattr(c, 'subtarget')]

• There may be some exceptions, but in general, symmetrize will mirror bone constraint targets. Using 2.92. Very handy. – Nathan Apr 29 at 19:34
• @Nathan Hm. In my case, the constraints pointed to bones in another armature, so that may be why it didn't mirror them. – Will Chen Apr 29 at 21:59