From 36a8b39da392fa06f59af2cea29fe0ee36fc24f4 Mon Sep 17 00:00:00 2001
From: Philipp Oeser <info@graphics-engineer.com>
Date: Tue, 7 Oct 2014 12:53:49 +0200
Subject: [PATCH] Fix T41871: F2 addon throws error if there is a material slot
 with no material assigned to it

Reviewed By: sergey
---
 mesh_f2.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/mesh_f2.py b/mesh_f2.py
index 61786d10a..4f85f3a0f 100644
--- a/mesh_f2.py
+++ b/mesh_f2.py
@@ -50,14 +50,15 @@ def get_uv_layer(ob, bm, mat_index):
             uv = me.uv_textures.active.name
     else:
         mat = ob.material_slots[mat_index].material
-        slot = mat.texture_slots[mat.active_texture_index]
-        if slot and slot.uv_layer:
-            uv = slot.uv_layer
-        else:
-            for tex_slot in mat.texture_slots:
-                if tex_slot and tex_slot.uv_layer:
-                    uv = tex_slot.uv_layer
-                    break
+        if mat is not None:
+            slot = mat.texture_slots[mat.active_texture_index]
+            if slot and slot.uv_layer:
+                uv = slot.uv_layer
+            else:
+                for tex_slot in mat.texture_slots:
+                    if tex_slot and tex_slot.uv_layer:
+                        uv = tex_slot.uv_layer
+                        break
     if uv:
         uv_layer = bm.loops.layers.uv.get(uv)
 
-- 
GitLab