Batch "Copy Transform" Script

Hi! for anyone exporting their customs rigs to game engines, I figured out a pretty useful little script. Once you made a duplicate of “DEF” bones and changed their name to “TGT”, You would select “DEF” Bones in Pose mode and run this script.

Hope it helps!
(Not really sure if it would work with rigify, I guess it does work but I haven’t tried, so if you do let everyone know!)

import bpy

for bone in bpy.context.selected_pose_bones:
bconstraint = bone.constraints.new(type=‘COPY_TRANSFORMS’)
bconstraint.target = bpy.context.active_object
bconstraint.subtarget = bone.name.replace(‘DEF’, ‘TGT’)