I’d like to rename some bones in an armature into something else, which i can define somewhere (in the script).
for example i want to define that if the armature has a bone named upper_arm_L it should be renamed forearm.L and so on.
I would also like to have a similar script for the vertex groups of an object
I assume these kind of utilities exist, but if not, would someone be kind to provide the code here…
import bpy
"""rename bones of an armature or vertex groups of a mesh object with a dictionary of name pairs"""
names = { # "old name" : "new name"
"Group":"group", # example
"Bone":"bone", # example
}
objects = bpy.context.selected_objects
for obj in objects:
if obj.type == 'ARMATURE':
for bone in obj.data.bones:
try:
bone.name = names[bone.name]
except:
pass
if obj.type == 'MESH':
for vg in obj.vertex_groups:
try:
vg.name = names[vg.name]
except:
pass