## stl-to-dxf is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by the ## Free Software Foundation; either version 2 of the License, or (at your ## option) any later version. stl-to-dxf is distributed in the hope that it ## will be useful, but WITHOUT ANY WARRANTY; without even the implied ## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See ## the GNU General Public License for more details. You should have ## received a copy of the GNU General Public License along with stl-to-dxf; if ## not, write to the Free Software Foundation, Inc., 59 Temple Place, ## Suite 330, Boston, MA 02111-1307 USA ## ## stl-to-dxf is Copyright (C) 2005 Chris Radek ## chris@timeguy.com import sys c=0 def header(): print " 0\nSECTION\n 2\nENTITIES" def footer(): print " 0\nENDSEC\n 0\nEOF\n\x1a" def start_face(): global c print " 0\n3DFACE\n 8\n0" c=0 def vertex(v): global c print " 1%d\n%s\n 2%d\n%s\n 3%d\n%s" % (c, v[0], c, v[1], c, v[2]) c+=1 if c==3: print " 13\n%s\n 23\n%s\n 33\n%s" % (v[0], v[1], v[2]) header() for line in sys.stdin.readlines(): if line.find("facet") == 0: start_face() continue if line.find("vertex") != -1: vertex(line.split()[-3:]) footer()