Skip to content

Instantly share code, notes, and snippets.

@evie404
Created July 10, 2020 16:09
Show Gist options
  • Save evie404/007697c47eef1e23fca9fdc741a43802 to your computer and use it in GitHub Desktop.
Save evie404/007697c47eef1e23fca9fdc741a43802 to your computer and use it in GitHub Desktop.
Blender copy bones
import bpy
destination_armature = bpy.data.objects['Destination Armature']
destination_root = destination_armature.pose.bones.get("ROOT_GROUND")
source_armature = bpy.data.objects['Source Armature']
source_root = source_armature.pose.bones.get("ROOT_GROUND")
bones = []
def add_children(root):
for child in root.children:
if child.name == "HEAD":
continue
add_children(child)
bones.append(child)
add_children(destination_root)
for bone in bones:
if source_armature.pose.bones.get(bone.name) is None:
continue
crc = bone.constraints.new('COPY_ROTATION')
crc.target = source_armature
crc.subtarget = bone.name
clc = bone.constraints.new('COPY_LOCATION')
clc.target = source_armature
clc.subtarget = bone.name
ctc = bone.constraints.new('COPY_TRANSFORM')
ctc.target = source_armature
ctc.subtarget = bone.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment