Created
January 30, 2017 21:15
-
-
Save schoeller/2ed175c582973c85f762d1b26c0b1cce to your computer and use it in GitHub Desktop.
Script to convert STL mesh to 3dfaces in DXF-format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
# Writing STL mesh to 3dfaces as DXF using dxfwrite | |
# Dirty script thus only for triangles | |
from dxfwrite import DXFEngine as dxf | |
drawing = dxf.drawing('test.dxf') | |
for line in sys.stdin.readlines(): | |
if line.find(" facet") == 0: | |
point = [] | |
face3d = [] | |
if line.find("vertex") != -1: | |
point.append(line.split()[-3:]) | |
if line.find(" endfacet") == 0: | |
face3d = dxf.face3d(point) | |
face3d['layer'] = 'faces' | |
face3d['color'] = 7 | |
drawing.add(face3d) | |
drawing.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment