From 3f2f9e4d628dd5a178e4ffaaaf879f70ee0eee69 Mon Sep 17 00:00:00 2001
From: M Bouchard Guillaume <guillaume.bouchard@liris.cnrs.fr>
Date: Wed, 8 Sep 2010 12:46:40 +0000
Subject: [PATCH] better use of blender api

---
 io_mesh_stl/blender_utils.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/io_mesh_stl/blender_utils.py b/io_mesh_stl/blender_utils.py
index 0177d0d63..76dc86b9b 100644
--- a/io_mesh_stl/blender_utils.py
+++ b/io_mesh_stl/blender_utils.py
@@ -31,12 +31,12 @@ def faces_from_mesh(ob, apply_modifier=False, triangulate=True):
         Split the quad into two triangles
     '''
 
-    if ob.type not in ('MESH', 'CURVE', 'SURFACE', 'META'):
-        return ()
-
     # get the modifiers
-    mesh = ob.create_mesh(bpy.context.scene,
-                          True, "PREVIEW") if apply_modifier else ob.data
+    try:
+        mesh = ob.create_mesh(bpy.context.scene,
+                                apply_modifier, "PREVIEW")
+    except SystemError:
+        return ()
 
     def iter_face_index():
         '''
-- 
GitLab