use more efficient looping
authorCampbell Barton <ideasman42@gmail.com>
Thu, 6 Sep 2012 07:21:22 +0000 (07:21 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 6 Sep 2012 07:21:22 +0000 (07:21 +0000)
mesh_select_vertex_groups.py

index ad9f07984d8b6f696cb9cd34054c634639548346..a1ea93b46a5368de6eb5d2b6a6e79f3dd33432eb 100644 (file)
@@ -165,18 +165,17 @@ def found_verts(vertex_group):
     obj = bpy.context.active_object
     if vertex_group == 'no group':
         for v in obj.data.vertices:
-            if v.index in used_vertexes and len(v.groups) == 0:
+            if v.index in used_vertexes and (not v.groups):
                 vgfound.append(v)
     else:
-        vgnum = -1
-        for vg in obj.vertex_groups:
-            if vg.name == vertex_group: vgnum = vg.index
+        vgnum = obj.vertex_groups.find(vertex_group)
         for v in obj.data.vertices:
             if v.index in used_vertexes:
-                found = False
                 for g in v.groups:
-                        if g.group == vgnum: found = True
-                if found: vgfound.append(v)
+                    if g.group == vgnum:
+                        vgfound.append(v)
+                        break
+
     print('%d vertexes found for %s' % (len(vgfound), vertex_group))
     return vgfound