[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4578] contrib/py/scripts/addons/ uv_texture_atlas.py: [TextureAtlas] Refactoring of bpy.ops.mesh uv textures .

paul geraskin paul_geraskin at mail.ru
Fri Jun 14 14:29:07 CEST 2013


Revision: 4578
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4578
Author:   mifth
Date:     2013-06-14 12:29:07 +0000 (Fri, 14 Jun 2013)
Log Message:
-----------
[TextureAtlas] Refactoring of bpy.ops.mesh uv textures.

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

Modified: contrib/py/scripts/addons/uv_texture_atlas.py
===================================================================
--- contrib/py/scripts/addons/uv_texture_atlas.py	2013-06-14 10:48:48 UTC (rev 4577)
+++ contrib/py/scripts/addons/uv_texture_atlas.py	2013-06-14 12:29:07 UTC (rev 4578)
@@ -318,14 +318,6 @@
     bl_label = "del Selected"
     bl_description = "Remove Selected Group and UVs"
     
-    ### removeUV method
-    def removeUV(self, mesh, name):
-             for uv in mesh.data.uv_textures:
-                   if uv.name == name:
-                        uv.active = True
-                        bpy.ops.mesh.uv_texture_remove()
-                        
-        
         #remove all modifiers
         #for m in mesh.modifiers:
             #bpy.ops.object.modifier_remove(modifier=m.name)
@@ -348,8 +340,10 @@
         
                   if object.type == 'MESH' and bpy.data.groups[group_name] in object.users_group:
 
-                         ### remove UV has crash
-                         self.removeUV(object, group_name)
+                         ### remove UV
+                         if object.data.uv_textures[group_name] is not None:
+                             tex = object.data.uv_textures[group_name]
+                             object.data.uv_textures.remove(tex)
 
                          #### remove from group
                          bpy.data.groups[group_name].objects.unlink(object)
@@ -390,8 +384,8 @@
                               UVLIST.append(uv.name)
                          
                    for uvName in UVLIST:
-                        object.data.uv_textures[uvName].active = True
-                        bpy.ops.mesh.uv_texture_remove()                  
+                        tex = object.data.uv_textures[uvName]
+                        object.data.uv_textures.remove(tex)
                   
                    UVLIST.clear() #clear array
                   
@@ -490,11 +484,11 @@
             
           
             if context.object.data.uv_textures.active is None:
-                bpy.ops.mesh.uv_texture_add()
+                context.object.data.uv_textures.new()
                 context.object.data.uv_textures.active.name = self.group_name
             else:    
                 if self.group_name not in context.object.data.uv_textures:
-                    bpy.ops.mesh.uv_texture_add()
+                    context.object.data.uv_textures.new()
                     context.object.data.uv_textures.active.name = self.group_name
                     context.object.data.uv_textures[self.group_name].active = True
                     context.object.data.uv_textures[self.group_name].active_render = True
@@ -534,9 +528,7 @@
                   scene.objects.active = obj
                   bpy.ops.object.delete(use_global=False)        
 
-
-  
-        
+                  
         me = bpy.data.meshes.new(self.group_name + '_mergedObject')
         ob_merge = bpy.data.objects.new(self.group_name + '_mergedObject', me)
         ob_merge.location = scene.cursor_location   # position object at 3d-cursor
@@ -594,9 +586,9 @@
                        UVLIST.append(uv.name)
                              
             for uvName in UVLIST:
-                 activeNowObject.data.uv_textures[uvName].active = True
-                 bpy.ops.mesh.uv_texture_remove()     
-            
+                 tex = activeNowObject.data.uv_textures[uvName]
+                 activeNowObject.data.uv_textures.remove(tex)
+
             UVLIST.clear() #clear array
             
             
@@ -694,6 +686,7 @@
                       for obj in groupSeparate.objects:
                            if obj != ob_merged:
                                ob_separeted = obj
+                               break
                                
                       ob_merged.select = False
                       #ob_separeted = context.selected_objects[0]



More information about the Bf-extensions-cvs mailing list