Last active
October 22, 2023 15:52
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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