[Bf-extensions-cvs] [3d61781] master: Resym vertex groups rewritten.

Eugenio Pignataro noreply at git.blender.org
Tue Mar 18 17:02:48 CET 2014


Commit: 3d61781218e0f53596b25d933d55da12369f54b9
Author: Eugenio Pignataro
Date:   Tue Mar 18 13:02:31 2014 -0300
https://developer.blender.org/rBAC3d61781218e0f53596b25d933d55da12369f54b9

Resym vertex groups rewritten.

===================================================================

M	oscurart_tools/oscurart_meshes.py

===================================================================

diff --git a/oscurart_tools/oscurart_meshes.py b/oscurart_tools/oscurart_meshes.py
index 7c7da7f..d0ab65c 100644
--- a/oscurart_tools/oscurart_meshes.py
+++ b/oscurart_tools/oscurart_meshes.py
@@ -94,44 +94,18 @@ class resymVertexGroups (bpy.types.Operator):
     bl_options = {"REGISTER", "UNDO"}
     def execute(self,context):
 
-        OBACTIVO = bpy.context.active_object
-        VGACTIVO = OBACTIVO.vertex_groups.active.index
-        
-        bpy.ops.object.mode_set(mode='EDIT')
-        BM = bmesh.from_edit_mesh(bpy.context.object.data)  
-        bpy.ops.mesh.select_all(action='DESELECT')
-        bpy.ops.object.vertex_group_select()
-        SELVER=[VERT.index for VERT in BM.verts[:] if VERT.select]   
-        
-        SYSBAR = os.sep     
-         
-        FILEPATH=bpy.data.filepath
-        ACTIVEFOLDER=FILEPATH.rpartition(SYSBAR)[0]
-        ENTFILEPATH= "%s%s%s_%s_SYM_TEMPLATE.xml" %  (ACTIVEFOLDER, SYSBAR, bpy.context.scene.name, bpy.context.object.name)
-        XML=open(ENTFILEPATH ,mode="r")        
-        SYMAP = eval(XML.readlines()[0])      
-        INL = [VERT for VERT in SYMAP if SYMAP[VERT] in SELVER if VERT!= SYMAP[VERT]] 
-        bpy.ops.mesh.select_all(action='DESELECT')
-        for VERT in INL:
-            BM.verts[VERT].select = True
-        bpy.ops.object.vertex_group_assign()    
-        bpy.ops.object.mode_set(mode='WEIGHT_PAINT')        
-        for VERT in INL:
-            for i, GRA in enumerate(OBACTIVO.data.vertices[SYMAP[VERT]].groups[:]):
-                if GRA.group == VGACTIVO:
-                    EM = i                    
-
-            for a, GRA in enumerate(OBACTIVO.data.vertices[VERT].groups[:]):     
-                if GRA.group == VGACTIVO:
-                    REC = a
-
-                    
-            OBACTIVO.data.vertices[VERT].groups[REC].weight = OBACTIVO.data.vertices[SYMAP[VERT]].groups[EM].weight  
-        XML.close()
-        SYMAP.clear()  
-      
-
-        print("===============(JOB DONE)=============")
+        with open("%s_%s_SYM_TEMPLATE.xml" % (os.path.join(os.path.dirname(bpy.data.filepath),bpy.context.scene.name),bpy.context.object.name)) as file:
+            ob = bpy.context.object
+            actgr = ob.vertex_groups.active
+            actind = ob.vertex_groups.active_index
+            ls = eval(file.read())
+            wdict = {left: actgr.weight(right)  for left, right in ls.items() for group in ob.data.vertices[right].groups  if group.group == actind}
+            actgr.remove([vert.index for vert in ob.data.vertices if vert.co[0] <= 0])       
+            for ind, weight in wdict.items():
+                actgr.add([ind],weight,'REPLACE')
+            bpy.context.object.data.update()                
+
+ 
         return {'FINISHED'}



More information about the Bf-extensions-cvs mailing list