From b52501d310b9be16d46c171c08ff9ff1e0adb61a Mon Sep 17 00:00:00 2001 From: Jeff Terrace Date: Thu, 10 Jul 2014 08:31:14 -0700 Subject: [PATCH] Fix writing to OBJ file with no material. (Half of #2) --- meshtool/filters/save_filters/save_obj_util.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/meshtool/filters/save_filters/save_obj_util.py b/meshtool/filters/save_filters/save_obj_util.py index 27fb14f..2a176e3 100644 --- a/meshtool/filters/save_filters/save_obj_util.py +++ b/meshtool/filters/save_filters/save_obj_util.py @@ -104,7 +104,8 @@ def write_obj(mesh, mtlfilename, f): f.write("\n") # Start using the right material - f.write("usemtl %s\n" % boundprim.material.id) + if boundprim.material: + f.write("usemtl %s\n" % boundprim.material.id) if emit_normals and emit_texcoords: format_string = "f %d/%d/%d %d/%d/%d %d/%d/%d" @@ -131,4 +132,4 @@ def write_obj(mesh, mtlfilename, f): tc_offset += boundprim.texcoordset[0].shape[0] f.write("\n") - \ No newline at end of file +