Renaming Bone script

Hi,

Need help. I don’t know python or script … but needed to run this script to rename bones from English to Japanese. Does anyone can tell me any thing wrong with this script? I click the “run script” button and it seems to run but the name of bones in the armature did not change. I am using 2.92 …

Appreciate some help with those that understand python …

You can write on script you can say any other one .If you can say other then please search on google it is more better for you Man.
Thanks

hi Andrew,
I am not clear what you are saying … are you suggesting that I search google for a python scripts that does bone remapping and try it out myself?
The thing is … I don’t know python . perhaps just wanted to know if the scripts I got in this example is a “valid” python script and am I right to just click the “play button” and it should run with some message that appears on the bottom window (a console I think) ??

Yes, I am saying that you can search in google your self. It is much better then you can ask other because you can ask the people and also people can tell you but you can’t understand So, that’s why I can say that. Don’t mind.
Be Happy Thanks

Following that logic we could close the entire #support section here; you can’t tell someone off for asking a question like this.

3 Likes

Hi,

I’m pretty noob with Python and Blender API, but I think this should work. Select your target armature, I don’t think it matters if you are in edit or object mode. Simply replace the dictionary items with your data.

import bpy

def rename_bones():
    
    dict = {
        'bone0': 'foo0',
        'bone1': 'foo1'
    }
    
    for b in bpy.context.object.data.bones:
        if b.name in dict.keys():
            b.name = dict[b.name]

rename_bones()

That .keys if will allow you to skip incorrectly named bones or extra bones which don’t have their name in dictionary.

2 Likes

Hi ezez,
Thanks so much … I used your scripts and works wonderfully. I am able to rename all my target armature’s bones now and able now to transfer bvh animation now to mmd rig. Your knowledge of Python clearly surpass me :slight_smile:

And thanks bartv for speaking for me.
Indeed I do need help and had received it with ezez solution.

Cheers.

2 Likes

dict = {
‘bone0’: ‘foo0’,
‘bone1’: ‘foo1’

In this code which is source name & target name pls?

left is source, right is target

like this:

dict = {
        'old_bone_name1': 'new_bone_name1',
        'old_bone_name2': 'new_bone_name2'
    }
1 Like

Thank you :pray::blush:

1 Like