[Script] Simple Daz To Blender Renaming (Vertex Groups/Bones) Script

Been playing with the Daz to Blender Bridge and it’s fun but all the bones and vertex group names are incompatible with Blender- left and right are denoted by an “l” or “r” prefix rather than a “_L” or “_R” suffix, so I wrote this simple script to fix that.

It will only rename groups or bones that have both a left and right variant. It detects this simply by name so if you have added two bones (say) that aren’t a pair called e.g. “lip” and “rip”, it will think they are and rename them, so beware. But it will leave “lip” on its own alone.

Just select any meshes and armatures that you want renaming and run the script in the text editor. Please let me know if you find any bugs.

#Daz To Blender Name Converter
#Converts names of Vertex Groups & Bones
#from lx|rx to x_L|x_R
#as per Blender naming convention
#
#by Ian Bland 2020

import bpy
import re

myScene = bpy.context.scene
myLayer = bpy.context.view_layer
myObjects = bpy.context.scene.objects

def main():

    sel_obs=bpy.context.selected_objects
    for obSrc in sel_obs:
        print("Doing:",obSrc.name)
        
        if obSrc.data:
            if obSrc.type=='MESH':
                print("Is a Mesh")
                obSrc_mesh = obSrc.data

                if obSrc.vertex_groups:
                    srcVGs = obSrc.vertex_groups
                    for VG in srcVGs:
                        print(VG.name)
                        if VG.name[:1] == "l":
                            mirrorName = "r" + VG.name[1:]
                            for chk in srcVGs:
                                if chk.name == mirrorName:
                                    VG.name=VG.name[1:] + "_L"
                                    chk.name = chk.name[1:] + "_R"
                                    print(VG.name)
                                    print(chk.name)
                                    
                        
            elif obSrc.type=='ARMATURE':
                print("Is an Armature")
                obSrc_arm = obSrc.data
                
                bonz = obSrc_arm.bones
                
                for Bon in bonz:
                    print (Bon.name)
                    if Bon.name[:1]=="l":
                        mirrorName= "r" + Bon.name[1:]
                        for chk in bonz:
                            if chk.name == mirrorName:
                                Bon.name =  Bon.name[1:] + "_L"
                                chk.name = chk.name[1:] + "_R"
                                print(Bon.name)
                                print(chk.name)
    return

main()

Very handy - thank you. Do you think this will work with other armatures (for ex. FBX, MMD, etc.)?

Well once a mesh or armature are loaded into Blender, the original format doesn’t matter. If it has the Daz type naming format, this will correct it. It would be easy to adapt to other naming conventions if they have their "L"s and "R"s in the wrong place :slight_smile: