[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32653] trunk/blender/release/scripts/op/ uv.py: change to Nathan's fix which also works with empty material slots.

Campbell Barton ideasman42 at gmail.com
Fri Oct 22 14:35:32 CEST 2010


Revision: 32653
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32653
Author:   campbellbarton
Date:     2010-10-22 14:35:31 +0200 (Fri, 22 Oct 2010)

Log Message:
-----------
change to Nathan's fix which also works with empty material slots.

Modified Paths:
--------------
    trunk/blender/release/scripts/op/uv.py

Modified: trunk/blender/release/scripts/op/uv.py
===================================================================
--- trunk/blender/release/scripts/op/uv.py	2010-10-22 11:51:10 UTC (rev 32652)
+++ trunk/blender/release/scripts/op/uv.py	2010-10-22 12:35:31 UTC (rev 32653)
@@ -113,7 +113,7 @@
     filepath = fw.__self__.name
     fw.__self__.close()
 
-    material_solids = [bpy.data.materials.new("uv_temp_solid") for i in range(len(mesh_source.materials))]
+    material_solids = [bpy.data.materials.new("uv_temp_solid") for i in range(max(1, len(mesh_source.materials)))]
     material_wire = bpy.data.materials.new("uv_temp_wire")
 
     scene = bpy.data.scenes.new("uv_temp")
@@ -166,13 +166,8 @@
     # place behind the wire
     obj_solid.location = 0, 0, -1
     
-    try:
-        obj_wire.material_slots[0].link = 'OBJECT'
-        obj_wire.material_slots[0].material = material_wire
-    except: # orig object didn't have material, add one here
-        obj_wire.data.materials.append(material_wire)
-        obj_wire.material_slots[0].link = 'OBJECT'
-        obj_wire.material_slots[0].material = material_wire
+    obj_wire.material_slots[0].link = 'OBJECT'
+    obj_wire.material_slots[0].material = material_wire
     
     
     # setup the camera
@@ -186,7 +181,9 @@
 
     # setup materials
     for i, mat_solid in enumerate(material_solids):
-        mat_solid.diffuse_color = mesh_source.materials[i].diffuse_color
+        if mesh_source.materials and mesh_source.materials[i]:
+            mat_solid.diffuse_color = mesh_source.materials[i].diffuse_color
+
         mat_solid.use_shadeless = True
         mat_solid.use_transparency = True
         mat_solid.alpha = 0.25





More information about the Bf-blender-cvs mailing list