# How to merge vertex groups?

I need this vertex group:

additively merged with this vertex group:

into a third new vertex group like this:

You can do this using the 'Vertex Weight Mix' modifier.

Here, I have an object with two vertex groups I would like to mix, one is a patch on the left and the other contains a patch on the right of the object:

'Vertex Group A' is set to the left patch (the vertex group I want to effect) and 'Vertex Group B' is the right patch (the vertex group I want to add into the other one). I then set the 'Mix Mode' to add and the vertex groups are mixed:

Applying the modifier will cause these mixed weights to be permanently written to the 'Left' vertex group.

If you want to preserve the contents of the 'Left' vertex group then you can make a copy of it before applying the modifier:

• Is there any way to reference the resulting vertex group from another menu (e.g., the cloth physics tab) without combining the two? Oct 9 '21 at 17:29

Fill in the required vertex group names, it will merge them into a 3rd new group:

import bpy

# EDIT THIS
vgroup_A_name = ""
vgroup_B_name = ""

# Get both groups and add them into third
ob = bpy.context.active_object
if (vgroup_A_name in ob.vertex_groups and
vgroup_B_name in ob.vertex_groups):

vgroup = ob.vertex_groups.new(name=vgroup_A_name+"+"+vgroup_B_name)

for id, vert in enumerate(ob.data.vertices):
available_groups = [v_group_elem.group for v_group_elem in vert.groups]
A = B = 0
if ob.vertex_groups[vgroup_A_name].index in available_groups:
A = ob.vertex_groups[vgroup_A_name].weight(id)
if ob.vertex_groups[vgroup_B_name].index in available_groups:
B = ob.vertex_groups[vgroup_B_name].weight(id)

# only add to vertex group is weight is > 0
sum = A + B
if sum > 0:

• Since you are adding each vertex to the new group, the actual vertex selection is gone. I actually need that selection in my case as well, so I've tried to improve your script to only add vertices assigned to the groups they copied from. One positive side effect is that we can merge more then 2 groups now. However I don't have that much experience in rigging like you, so what do you think about this version?
– p2or
Aug 23 '17 at 16:44
• @p2or I am not sure if I understand the problem correctly or what your goal is. Vertex selection is gone? There shouldn't be such a thing. This script shouldn't alter any data, just adds extra vertex group. It could be expanded to work with any number of groups if that is your goal. Your script also works fine, I have no issue with it. As a tip you can omit the clamp part though, blender does this automatically. Aug 23 '17 at 17:44
• Thanks for taking the time and testing the script @Jerryno. Great! No, your script appends/adds every vertex to the new group. You can check that by switching into edit mode and clicking the select button after running the thing, then the operator selects all vertices even if their weight value is 0, right? I know that you wrote this long time ago and that wasn't your actual goal, only thought we could improve your answer... Again, lack of experience here so thanks for your tip and testing the script.
– p2or
Aug 23 '17 at 20:30
• @p2or Oh, this, sure, you are right. If the final weight is 0, the vertex can be omitted and not added to the group. Right. Improved :) Aug 24 '17 at 17:03
• I just had some time to test your code. I think testing whether A+B is 0, is only a partial solution. In case there is a vertex which belongs to both original groups, but also has a weight value of 0, the current approach obviously won't add it to the new group properly so I think the better approach is to test if MeshVertex.groups collection is not empty as well as checking whether the correspondig vertex is part of "Group" and "Group.001" before adding the vertex to the new group. I adapted your code here to reflect that.
– p2or
Aug 25 '17 at 10:46

## EDIT: this solution does not work

When copying vertices into another group, it doesn't preserve the vertex weights and it assigns the value set in the Weight slider:

(thanks to @Jerryno)