Skip to content

Instantly share code, notes, and snippets.

@Airyzz
Created December 13, 2019 09:48
Show Gist options
  • Save Airyzz/035e8596b552d4f064feeab4b01a2d80 to your computer and use it in GitHub Desktop.
Save Airyzz/035e8596b552d4f064feeab4b01a2d80 to your computer and use it in GitHub Desktop.
import bpy
armature = bpy.context.active_object
bpy.ops.object.empty_add(type='PLAIN_AXES', location=(0,0,0))
parent = bpy.context.selected_objects[0]
parent.name = 'metarig'
for bone in armature.pose.bones:
matrix = (armature.matrix_world.inverted() @ bone.matrix)
Z = matrix[0][3]
Y = matrix[2][3]
X = matrix[1][3]
bpy.ops.object.empty_add(type='PLAIN_AXES', location=(0, 0, 0))
axis = bpy.context.selected_objects[0]
axis.name = 'metarig.' + bone.name
axis.parent = parent
axis.scale = (5,5,5)
crc = axis.constraints.new('COPY_ROTATION')
crc.target = armature
crc.subtarget = bone.name
crc.use_offset = True
clc = axis.constraints.new('COPY_LOCATION')
clc.target = armature
clc.subtarget = bone.name
clc.use_offset = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment