Blender

Blender

Not enough ratings
Delete unweighted, unused vertex groups
By _MaZ_TeR_
Only made this thread so I could easily find this trick in the future.

Credits to this thread:
https://blenderartists.org/t/batch-delete-vertex-groups-script/449881/22
   
Award
Favorite
Favorited
Unfavorite
According to the comments in the thread, the plugin doesn't work by itself in Blender 3.0 anymore, but running the script in the text editor of Blender does work as confirmed by me.

Before you run the script, select the object from which you want the unweighted vertex groups removed.

Here is the code:


import bpy from bpy.types import Operator ob = bpy.context.object ob.update_from_editmode() vgroup_used = {i: False for i, k in enumerate(ob.vertex_groups)} for v in ob.data.vertices: for g in v.groups: if g.weight > 0.0: vgroup_used[g.group] = True for i, used in sorted(vgroup_used.items(), reverse=True): if not used: ob.vertex_groups.remove(ob.vertex_groups[letter i])


And here is it, but it works with multiple objects selected:

import bpy from bpy.types import Operator # Loop over all selected objects for ob in bpy.context.selected_objects: # Check if the object is a mesh if ob.type == 'MESH': ob.update_from_editmode() vgroup_used = {i: False for i, k in enumerate(ob.vertex_groups)} for v in ob.data.vertices: for g in v.groups: if g.weight > 0.0: vgroup_used[g.group] = True for i, used in sorted(vgroup_used.items(), reverse=True): if not used: ob.vertex_groups.remove(ob.vertex_groups[letter i])

Note that change the "letter i" sections to just i, I can't put the square brackets because it formats the text to italian and deletes the part of the code.
4 Comments
Artiko240 Sep 6, 2023 @ 4:08am 
True
_MaZ_TeR_  [author] Aug 25, 2023 @ 12:24pm 
The better question is, why not?
Artiko240 Aug 25, 2023 @ 10:40am 
why the cat
N7Legion Aug 15, 2023 @ 11:32pm 
I have a different script, which is a lot easier to remove the unused vertex groups with a button. Can be easily located under Data > Vertex Groups > Special menu

https://cdn.discordapp.com/attachments/488722739922993152/1141257827520872488/Remove_unused_vertex_groups.py