# Mass replace names in vertex groups

I have a character that is setup with a rig and vertex groups. I want to switch to using Rigify. Rigify has the same bones as the current setup, but different names. To save time weight painting, I need to rename all the bone weight vertex groups to match the bone names used by Rigify instead of the current rig. So I need a tool or script that will take a bone name such as lowerarm_L and rename it to Forearm.L (or whatever rigify calls it.) I can make the bone name list myself.

I will need to do this on multiple characters, so making a script out of it would be very helpful. How can this be done?

The list of vertex groups can be found in the object properties, we just need to search for the names we want and rename them.

You could fill in name_list from the start or just add one or two names as you find them and re-run the script. This is set to rename vertex groups in the active object.

import bpy

name_list = [
# old name - new name
['lowerarm_L','forearm.L'],
['lowerarm_R','forearm.R'],
['upperarm_L','upper_arm.L'],
['upperarm_R','upper_arm.R'],
]

v_groups = bpy.context.active_object.vertex_groups
for n in name_list:
if n[0] in v_groups:
v_groups[n[0]].name = n[1]


Note that matching names this way is case-sensitive, for an insensitive match use -

v_groups = bpy.context.active_object.vertex_groups
for n in name_list:
for vn in v_groups:
if vn.name.lower() == n[0].lower():
vn.name = n[1]


Have you looked into the Name Panel Addon?

It's really versatile batch naming tool for various data blocks, including Vertex Groups and batch name copying.

It even has some advanced features like Auto Naming, though I've never used those myself.

It's totally free and open source, although I'd consider buying it over at the Blender Market if you find it useful or if it helped you, simply to show encouragement and support to the developer.

I'm planing on doing it myself.

• That looks really useful for a lot of things. I am still figuring out how to use it, but it does not seem to let me make a list of term to replace other terms with. I have to do it one at a time still? It looks like I'll still need a script if I want to rename all my groups from a pre made list with one click (although a script that calls this addon would probably be easier.) – Drudge Oct 2 '16 at 8:04
• The addon is quite powerful but also a bit hard to grasp at once. I only use a limited subset of the features myself, but as far as I know you can only find and replace one item at a time, so maybe a script that calls the addon is the solution. The author is quite open to suggestions, maybe he can come up with something although he mentioned being in the midst of a big rewrite, so he may not want to change much in the current addon iteration – Duarte Farrajota Ramos Oct 2 '16 at 12:41