diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-01-14 22:31:42 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-01-14 22:31:42 +0300 |
commit | 5722bc15cd193bf8c083e282c3ad36344aab3832 (patch) | |
tree | bc90473942dfa41e0314a2fc42e533f13b466dcb /io_mesh_stl | |
parent | 55c6ce612617ca2f5aca0ecefe4ddf381100f94a (diff) |
bugfix [#25635] STL export results in error
also made some pep8 corrections
Diffstat (limited to 'io_mesh_stl')
-rw-r--r-- | io_mesh_stl/blender_utils.py | 28 | ||||
-rw-r--r-- | io_mesh_stl/stl_utils.py | 2 |
2 files changed, 18 insertions, 12 deletions
diff --git a/io_mesh_stl/blender_utils.py b/io_mesh_stl/blender_utils.py index a043a8f3..751f2586 100644 --- a/io_mesh_stl/blender_utils.py +++ b/io_mesh_stl/blender_utils.py @@ -38,16 +38,20 @@ def faces_from_mesh(ob, apply_modifier=False, triangulate=True): except SystemError: return () - def iter_face_index(): - ''' - From a list of faces, return the face triangulated if needed. - ''' - for face in mesh.faces: - if triangulate and len(face.vertices) == 4: - yield face.vertices[:3] - yield face.vertices[2:] + [face.vertices[0]] - else: - yield list(face.vertices) - - return ([tuple(mesh.vertices[index].co * ob.matrix_world) + if triangulate: + # From a list of faces, return the face triangulated if needed. + def iter_face_index(): + for face in mesh.faces: + vertices = face.vertices[:] + if len(vertices) == 4: + yield vertices[0], vertices[1], vertices[2] + yield vertices[2], vertices[3], vertices[0] + else: + yield vertices + else: + def iter_face_index(): + for face in mesh.faces: + yield face.vertices[:] + + return ([(mesh.vertices[index].co * ob.matrix_world)[:] for index in indexes] for indexes in iter_face_index()) diff --git a/io_mesh_stl/stl_utils.py b/io_mesh_stl/stl_utils.py index 734204b8..9524ecb3 100644 --- a/io_mesh_stl/stl_utils.py +++ b/io_mesh_stl/stl_utils.py @@ -65,6 +65,7 @@ class ListDict(dict): BINARY_HEADER = 80 BINARY_STRIDE = 12 * 4 + 2 + def _is_ascii_file(data): ''' This function returns True if the data represents an ASCII file. @@ -77,6 +78,7 @@ def _is_ascii_file(data): return not data.size() == BINARY_HEADER + 4 + BINARY_STRIDE * size + def _binary_read(data): # an stl binary file is # - 80 bytes of description |