[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1401] trunk/py/scripts/addons/ io_mesh_stl: bugfix [#25635] STL export results in error

Campbell Barton ideasman42 at gmail.com
Fri Jan 14 20:31:43 CET 2011


Revision: 1401
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1401
Author:   campbellbarton
Date:     2011-01-14 19:31:42 +0000 (Fri, 14 Jan 2011)
Log Message:
-----------
bugfix [#25635] STL export results in error
also made some pep8 corrections

Modified Paths:
--------------
    trunk/py/scripts/addons/io_mesh_stl/blender_utils.py
    trunk/py/scripts/addons/io_mesh_stl/stl_utils.py

Modified: trunk/py/scripts/addons/io_mesh_stl/blender_utils.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_stl/blender_utils.py	2011-01-14 18:10:02 UTC (rev 1400)
+++ trunk/py/scripts/addons/io_mesh_stl/blender_utils.py	2011-01-14 19:31:42 UTC (rev 1401)
@@ -38,16 +38,20 @@
     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)
+    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 ([tuple(mesh.vertices[index].co * ob.matrix_world)
+    return ([(mesh.vertices[index].co * ob.matrix_world)[:]
              for index in indexes] for indexes in iter_face_index())

Modified: trunk/py/scripts/addons/io_mesh_stl/stl_utils.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_stl/stl_utils.py	2011-01-14 18:10:02 UTC (rev 1400)
+++ trunk/py/scripts/addons/io_mesh_stl/stl_utils.py	2011-01-14 19:31:42 UTC (rev 1401)
@@ -65,6 +65,7 @@
 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 @@
 
     return not data.size() == BINARY_HEADER + 4 + BINARY_STRIDE * size
 
+
 def _binary_read(data):
     # an stl binary file is
     # - 80 bytes of description



More information about the Bf-extensions-cvs mailing list