I often use Blender to port models between game engines for personal-use game mods, which means I frequently have to rename the bones in accordance with the rules of different game engines.
I already have a script that works perfectly for renaming vertex groups (should I import a mesh without its skeleton)...
import bpy name_list = [ # old name - new name ['Bip01 Head','Bip01_Head'], ['Bip01 Neck1','Bip01_Neck1'], ## Rest of the list ## Each version of the script has a different list, specific to the game engines I'm porting between. ['Bip01 Finger41.R', 'Bip01_R_Finger41'], ['Bip01 Finger42.R', 'Bip01_R_Finger42'] ] v_groups = bpy.context.active_object.vertex_groups for n in name_list: if n in v_groups: v_groups[n].name = n
... select desired object, run script, all recognised vertex groups get renamed.
However, my attempts to adapt a version that will rename bones instead...
bone_list = bpy.context.visible_bones for n in name_list: if n in bone_list: bone_list[n].name = n
... simply has no effect. (I have also tried with the bpy.context.editable_bones, bpy.context.selected_bones and bpy.context.selected_editable_bones contexts).
There's no errors on the console (although I can definitely provoke errors - by trying to run the script in the wrong 3D view mode, misspelling commands, etc - so it's not that the script isn't even trying to run), and the bone names in the armature definitely match the names in the script's list (I have now copy-pasted some names to check, but the Vertex group version of the script definitely works to rename the matched groups on the associated meshes).
I'm out of my element when it comes to Python in Blender, so I'm really quite stuck as to why this is simply failing to work. Words of wisdom would be appreciated.