Skip to content

Instantly share code, notes, and snippets.

@jesgs
Last active October 22, 2023 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesgs/df411c24c17a8e0e838950097ef0bf1a to your computer and use it in GitHub Desktop.
Save jesgs/df411c24c17a8e0e838950097ef0bf1a to your computer and use it in GitHub Desktop.
Python script for renaming armature bones in Blender. Specific to figures being imported from Daz Studio/Poser to Blender.
import bpy
import re
def rename_all_bones():
armature = bpy.context.active_object
bones = armature.data.bones
for bone in bones:
new_name = rename_bone(bone.name)
if new_name is not "":
armature.data.bones[bone.name].name = new_name
def rename_bone(name):
if "root" in name:
return ""
if name.find('l', 0, 1) is not -1:
print(name)
name = name[1:] + '.L'
elif name.find('r', 0, 1) is not -1:
name = name[1:] + '.R'
return name
rename_all_bones()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment