2.8 Can I automatically remove all vertex groups that are not influencing any mesh?

When I assign Apply Automatic Weights I want to then delete all unused vertex for simplicity sake when my character to rig is composed of many mesh parts.

The Delete Unlocked Vertex Group option helps but I wish I didn't have to delete hundreds of vertex groups by hand to begin with. I know sometimes a character to rig is one mesh but for when it isn't I wish there could be a way to just have vertex groups created only if they are influencing the part of the mesh.

eg: I don't need feet and finger vertex groups for the head mesh.

Ideally, if I can remove all vertex groups that are not influencing any mesh with one click would be optimal.

Is there a script or add-on that can help me speed up removing unwanted vertex?

• I am of the recollection that in <= 2.79 you could select pose bones then shift select the mesh (or vice versa) and reset / adjust the bone weighting on a selected bone basis. Couldn't find how to do similar with 2.8 since it swaps the mode of all objects. For separate meshes could look into separating your armatures accordingly and bone parent them to other armatures, eg have a face rig parented to head bone. There are of course pros and cons. Nov 14 '19 at 6:44
• There's an addon that does this job: gumroad.com/l/Gxkbp May 10 '20 at 20:37

You can just:

• select your skeleton
• get a Text Editor window
• paste the script below & run
import bpy
bpy.ops.object.mode_set(mode='OBJECT')
skeleton = bpy.context.object

for object in [object for object in bpy.context.scene.objects]:
if object.type == 'MESH' and len(object.vertex_groups) > 0 and skeleton == object.find_armature():
for vGroup in object.vertex_groups:
if skeleton.data.bones.get(vGroup.name) is None:
object.vertex_groups.remove(vGroup)


I still think the first answer is valid for those searching & do not feel comfortable running scripts to just mass delete everything in advance. Hence the 2 answers. The question was a year old, and I also assumed the original asker had moved on.

• The first answer was not valid as it solved a problem that was never asked. I dunno how I stumbled upon this page but I'm glad I did. Now I got a proper answer to my question. This answer is very appreciated. Thanks! Oct 23 '20 at 10:29
• Selected the skeleton (rigify) Pasted the script RUN. My character's eyes has vertex groups for toes. So it's not working in my case. Dec 31 '20 at 4:31

There is an operator bpy.ops.object.vertex_group_remove(all=True). Since you are going to be adding all new vertex groups when the Armature modifier, seems like just deleting them all BEFORE would be a lot simpler.

I do not know if there is user interface, which will get this called or not, though.

• I didn't ask for your opinion, I was asking if there was a feature. Oct 19 '20 at 18:21