[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3720] contrib/py/scripts/addons/ mesh_select_vertex_groups.py: use more efficient looping

Campbell Barton ideasman42 at gmail.com
Thu Sep 6 09:21:24 CEST 2012


Revision: 3720
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3720
Author:   campbellbarton
Date:     2012-09-06 07:21:22 +0000 (Thu, 06 Sep 2012)
Log Message:
-----------
use more efficient looping

Modified Paths:
--------------
    contrib/py/scripts/addons/mesh_select_vertex_groups.py

Modified: contrib/py/scripts/addons/mesh_select_vertex_groups.py
===================================================================
--- contrib/py/scripts/addons/mesh_select_vertex_groups.py	2012-09-06 06:53:59 UTC (rev 3719)
+++ contrib/py/scripts/addons/mesh_select_vertex_groups.py	2012-09-06 07:21:22 UTC (rev 3720)
@@ -165,18 +165,17 @@
     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
 



More information about the Bf-extensions-cvs mailing list