From 888e3c02872d5d33b93356ddf98808e71c85ca83 Mon Sep 17 00:00:00 2001
From: Campbell Barton <ideasman42@gmail.com>
Date: Tue, 2 Aug 2011 10:25:12 +0000
Subject: [PATCH] fix [#28146] OBJ fails when mehs has no material

---
 io_scene_obj/export_obj.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/io_scene_obj/export_obj.py b/io_scene_obj/export_obj.py
index 3c721643c..b043ec6de 100644
--- a/io_scene_obj/export_obj.py
+++ b/io_scene_obj/export_obj.py
@@ -383,6 +383,11 @@ def write_file(filepath, objects, scene,
             materials = me.materials[:]
             material_names = [m.name if m else None for m in materials]
 
+            # avoid bad index errors
+            if not materials:
+                materials = [None]
+                material_names = [""]
+
             # Sort by Material, then images
             # so we dont over context switch in the obj file.
             if EXPORT_KEEP_VERT_ORDER:
-- 
GitLab