Page 1 of 1

How to get to know how much vertices is inside vertexGroup?

Posted: Sat Nov 02, 2013 11:52 pm
by anders211
I see bug in blender interface:
http://www.blender.org/documentation/bl ... ertexGroup

There is none way to get to know how much vertices are in this vertex group.

Posted: Sun Nov 03, 2013 12:37 am
by CoDEmanX
You can do that like:

Code: Select all

ob = bpy.context.object
vgroup_verts = {vgroup.name: [] for vgroup in ob.vertex_groups}

for v in ob.data.vertices:
    for g in v.groups:
        vgroup_verts[ob.vertex_groups[g.group].name].append(v.index)

for vgroup in vgroup_verts:
    vcount = len(vgroup_verts[vgroup])
    print("Vertex Group '%s' has %i %s." % (vgroup, vcount, "vertex" if vcount == 1 else "vertices"))