Commit 23150219 authored by sumpfralle's avatar sumpfralle

fixed the order of vertices when exporting a model to an STL file

disabled code for adding comments to the STL files
fixed two sample STL files with wrong order of vertices


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@718 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 9db130d8
solid "model"; Produced by pycam, 2010-09-23
;PYCAM-META-DATA: Filename: samples/Box2.stl
;PYCAM-META-DATA: Timestamp: 2010-09-23 20:22:11.660612
;PYCAM-META-DATA: Version: 0.3
solid "model"; Produced by pycam (v0.3), 2010-10-03
facet normal 0.707143 -0.408041 0.577452
outer loop
vertex 2.563112 -5.599983 2.267282
vertex 2.562797 -2.393577 4.533387
vertex 5.339321 -3.997340 0.000022
vertex 2.562797 -2.393577 4.533387
vertex 2.563112 -5.599983 2.267282
endloop
endfacet
facet normal 0.707143 -0.408041 0.577452
outer loop
vertex 5.339321 -3.997340 0.000022
vertex 2.562797 -2.393577 4.533387
vertex 5.339006 -0.790934 2.266127
vertex 2.562797 -2.393577 4.533387
vertex 5.339321 -3.997340 0.000022
endloop
endfacet
facet normal -0.707143 0.408041 -0.577452
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.562824 -2.395226 -2.267260
vertex -0.213699 -0.791464 2.266105
vertex 2.562824 -2.395226 -2.267260
vertex -0.213384 -3.997869 0.000000
endloop
endfacet
facet normal -0.707143 0.408041 -0.577452
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 2.562824 -2.395226 -2.267260
vertex 2.562510 0.811179 -0.001155
vertex 2.562824 -2.395226 -2.267260
vertex -0.213699 -0.791464 2.266105
endloop
endfacet
facet normal 0.707070 0.408176 -0.577446
outer loop
vertex 5.339006 -0.790934 2.266127
vertex 2.562510 0.811179 -0.001155
vertex 2.562824 -2.395226 -2.267260
vertex 2.562510 0.811179 -0.001155
vertex 5.339006 -0.790934 2.266127
endloop
endfacet
facet normal 0.707070 0.408176 -0.577446
outer loop
vertex 5.339006 -0.790934 2.266127
vertex 2.562824 -2.395226 -2.267260
vertex 5.339321 -3.997340 0.000022
vertex 2.562824 -2.395226 -2.267260
vertex 5.339006 -0.790934 2.266127
endloop
endfacet
facet normal -0.707070 -0.408176 0.577446
outer loop
vertex -0.213384 -3.997869 0.000000
vertex -0.213699 -0.791464 2.266105
vertex 2.562797 -2.393577 4.533387
vertex -0.213699 -0.791464 2.266105
vertex -0.213384 -3.997869 0.000000
endloop
endfacet
facet normal -0.707070 -0.408176 0.577446
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.562797 -2.393577 4.533387
vertex 2.563112 -5.599983 2.267282
vertex 2.562797 -2.393577 4.533387
vertex -0.213384 -3.997869 0.000000
endloop
endfacet
facet normal -0.000080 0.816637 0.577152
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 2.562510 0.811179 -0.001155
vertex 5.339006 -0.790934 2.266127
vertex 2.562510 0.811179 -0.001155
vertex -0.213699 -0.791464 2.266105
endloop
endfacet
facet normal -0.000080 0.816637 0.577152
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 5.339006 -0.790934 2.266127
vertex 2.562797 -2.393577 4.533387
vertex 5.339006 -0.790934 2.266127
vertex -0.213699 -0.791464 2.266105
endloop
endfacet
facet normal 0.000080 -0.816637 -0.577152
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.563112 -5.599983 2.267282
vertex 5.339321 -3.997340 0.000022
vertex 2.563112 -5.599983 2.267282
vertex -0.213384 -3.997869 0.000000
endloop
endfacet
facet normal 0.000080 -0.816637 -0.577152
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 5.339321 -3.997340 0.000022
vertex 2.562824 -2.395226 -2.267260
vertex 5.339321 -3.997340 0.000022
vertex -0.213384 -3.997869 0.000000
endloop
endfacet
endsolid
This diff is collapsed.
......@@ -21,6 +21,7 @@ You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
from pycam import VERSION
import datetime
import os
......@@ -46,15 +47,21 @@ class STLExporter:
def get_output_lines(self):
date = datetime.date.today().isoformat()
yield """solid "%s"; Produced by %s, %s""" % (self.name, self.created_by, date)
yield """solid "%s"; Produced by %s (v%s), %s""" \
% (self.name, self.created_by, VERSION, date)
# sadly STL does not seem to support comments
"""
if self.comment:
for line in self.comment.split(self.linesep):
yield(";%s" % line)
"""
for tr in self.model.triangles():
norm = tr.normal.normalized()
yield "facet normal %f %f %f" % (norm.x, norm.y, norm.z)
yield " outer loop"
for p in (tr.p1, tr.p2, tr.p3):
# Triangle vertices are stored in clockwise order - thus we need
# to reverse the order (STL expects counter-clockwise orientation).
for p in (tr.p3, tr.p2, tr.p1):
yield " vertex %f %f %f" % (p.x, p.y, p.z)
yield " endloop"
yield "endfacet"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment