Skip to content

Instantly share code, notes, and snippets.

@kerbeh
Forked from naelstrof/mixamoToBlenderBoneNames.py
Created December 5, 2019 01:00
Show Gist options
  • Save kerbeh/c6af2cfcd7d79cd8f43574b983548904 to your computer and use it in GitHub Desktop.
Save kerbeh/c6af2cfcd7d79cd8f43574b983548904 to your computer and use it in GitHub Desktop.
Convert Mixamo rig bone names (as imported to Blender via FBX) to standard Blender bone names. This is especially use if your mesh uses the 'mirror' modifier. 1 - Backup your Blend. 2 - In action editor disconnect any animation connected to the rig. 3 - Paste the script in a text window and select "run script". 4 - Notice that all bone names are…
# IMPORTANT: make sure no animation is assigned
# to the rig before you run this script,
# otherwise linked animation data will be corrupted.
import bpy
# ----------------------------------
# Mixamo left/right bone names start with 'Left'/'Right'
# Instead we apply Blender's standard .L/.R suffix
# and get rid of long suffix
# ----------------------------------
def makeStandardBoneName(x):
x = x[10:]
if 'Left' in x:
x = x[4:]+".L"
if 'Right' in x:
x = x[5:]+".R"
return x
# ----------------------------------
# Standardize bone names.
# ----------------------------------
for armature in bpy.data.armatures:
for bone in armature.bones:
n = bone.name
if 'mixamorig:' in n:
bone.name = makeStandardBoneName(n)
# ----------------------------------
# Convert animation channel names
# ----------------------------------
for action in bpy.data.actions:
for curve in action.fcurves:
p = curve.data_path
if 'mixamorig:' in p:
e = p.split("\"")
x = makeStandardBoneName(e[1])
curve.data_path = e[0]+"\""+x+"\""+e[2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment