bugfix for [#6818] object_find.py assumes active uv layer is set
authorCampbell Barton <ideasman42@gmail.com>
Sun, 10 Jun 2007 04:10:25 +0000 (04:10 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 10 Jun 2007 04:10:25 +0000 (04:10 +0000)
was assuming meshes had UVs

release/scripts/object_find.py

index 4ce93998f00d5e6702a4d08b461357fdbce046b4..0cfd6ad1d92b91f2b8ca72fa59cd0fa6a8581bdc 100644 (file)
@@ -41,20 +41,27 @@ import BPyMessages
 
 def get_object_images(ob):
        # Could optimize this
-       if ob.type == 'Mesh':
-               unique_images = {}
-               me = ob.getData(mesh=1)
-               orig_uvlayer = me.activeUVLayer 
-               
-               for uvlayer in me.getUVLayerNames():
-                       me.activeUVLayer = uvlayer
-                       for f in me.faces:
-                               i = f.image
-                               if i: unique_images[i.name] = i
-               
-               me.activeUVLayer = orig_uvlayer
-               
-               return unique_images.values()
+       if ob.type != 'Mesh':
+               return []
+       
+       me = ob.getData(mesh=1)
+
+       if not me.faceUV:
+               return []
+
+       unique_images = {}
+       
+       orig_uvlayer = me.activeUVLayer 
+       
+       for uvlayer in me.getUVLayerNames():
+               me.activeUVLayer = uvlayer
+               for f in me.faces:
+                       i = f.image
+                       if i: unique_images[i.name] = i
+       
+       me.activeUVLayer = orig_uvlayer
+       
+       return unique_images.values()
        
        # Todo, support other object types, materials
        return []