[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4633] trunk/py/scripts/addons/ uv_texture_atlas.py: [TextureAtlas] fixes if non MESH objects are in the group.

paul geraskin paul_geraskin at mail.ru
Sat Jul 20 22:28:55 CEST 2013


Revision: 4633
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4633
Author:   mifth
Date:     2013-07-20 20:28:54 +0000 (Sat, 20 Jul 2013)
Log Message:
-----------
[TextureAtlas] fixes if non MESH objects are in the group.
0.2.0 version now.

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

Modified: trunk/py/scripts/addons/uv_texture_atlas.py
===================================================================
--- trunk/py/scripts/addons/uv_texture_atlas.py	2013-07-18 17:34:14 UTC (rev 4632)
+++ trunk/py/scripts/addons/uv_texture_atlas.py	2013-07-20 20:28:54 UTC (rev 4633)
@@ -20,7 +20,7 @@
 bl_info = {
     "name": "Texture Atlas",
     "author": "Andreas Esau, Paul Geraskin, Campbell Barton",
-    "version": (0, 18),
+    "version": (0, 2, 0),
     "blender": (2, 6, 7),
     "location": "Properties > Render",
     "description": "A simple Texture Atlas for unwrapping many objects. It creates additional UV",
@@ -429,10 +429,9 @@
         item.resolution = '1024'
         scene.ms_lightmap_groups_index = len(scene.ms_lightmap_groups) - 1
 
-        # if len(context.selected_objects) > 0:
+        # Add selested objects to group
         for object in context.selected_objects:
-            # scene.objects.active = object
-            if context.active_object.type == 'MESH':
+            if object.type == 'MESH':
                 obj_group.objects.link(object)
 
         return {'FINISHED'}
@@ -493,24 +492,41 @@
         image.generated_type = 'COLOR_GRID'
         image.generated_width = self.resolution
         image.generated_height = self.resolution
+        obj_group = bpy.data.groups[self.group_name]
 
-        for object in bpy.data.groups[self.group_name].objects:
-            if object.data.uv_textures.active is None:
-                tex = object.data.uv_textures.new()
-                tex.name = self.group_name
+        # non MESH objects for removal list
+        NON_MESH_LIST = []
+
+        for object in obj_group.objects:
+            # Remove non MESH objects
+            if object.type != 'MESH':
+                NON_MESH_LIST.append(object)
+
             else:
-                if self.group_name not in object.data.uv_textures:
+                # Add Image to faces
+                if object.data.uv_textures.active is None:
                     tex = object.data.uv_textures.new()
                     tex.name = self.group_name
-                    tex.active = True
-                    tex.active_render = True
                 else:
-                    tex = object.data.uv_textures[self.group_name]
-                    tex.active = True
-                    tex.active_render = True
+                    if self.group_name not in object.data.uv_textures:
+                        tex = object.data.uv_textures.new()
+                        tex.name = self.group_name
+                        tex.active = True
+                        tex.active_render = True
+                    else:
+                        tex = object.data.uv_textures[self.group_name]
+                        tex.active = True
+                        tex.active_render = True
 
-            for face_tex in tex.data:
-                face_tex.image = image
+                for face_tex in tex.data:
+                    face_tex.image = image
+
+        # remove non NESH objects
+        for object in NON_MESH_LIST:
+            obj_group.objects.unlink(object)
+
+        NON_MESH_LIST.clear() # clear array
+
         return{'FINISHED'}
 
 



More information about the Bf-extensions-cvs mailing list