1

I am figuring out a way to check if vertex group is empty or not. if it contains at least 1 vertex or totally empty.

I am trying to make if condition to check for empty vertex group and delete the vertex group if it's empty

can I do this with vertex group data or should i use functions from bmesh

Profz3D
  • 11
  • 3
  • it looks like there is a script here: https://blender.stackexchange.com/questions/16517/how-to-quickly-remove-all-zero-weight-vertex-groups – moonboots Aug 29 '18 at 09:41

1 Answers1

2

Using list comprehension

similar to that used in this answer

Because we are only interested in empty group will use python any to move on quickly when a non empty group is found.

import bpy
ob = bpy.context.object
me = ob.data
for vg in ob.vertex_groups:
    mtvg = not any(vg.index in [g.group for g in v.groups] for v in me.vertices)
    print(vg.name, mtvg)

Then if vertex group vg is empty can remove with

ob.vertex_groups.remove(vg)
batFINGER
  • 84,216
  • 10
  • 108
  • 233