Skip to content

Instantly share code, notes, and snippets.

@eldritchideen
Last active August 29, 2015 14:05
Show Gist options
  • Save eldritchideen/336fc3b823d2d0b89a13 to your computer and use it in GitHub Desktop.
Save eldritchideen/336fc3b823d2d0b89a13 to your computer and use it in GitHub Desktop.
Getting points out of a DXF file
import dxfgrabber
dxf = dxfgrabber.readfile('surface0.dxf')
all_surface_entities = [entity for entity in dxf.entities if entity.layer == '0']
all_progress_line_entities = [entity for entity in dxf.entities if entity.layer == 'Progress Line']
f = open('surface_points.csv', 'w')
# List of Point objects
for p in all_surface_entities:
f.write('{},{},{}\n'.format(p.point[0],p.point[1],p.point[2]))
f.close()
f = open('prog_line_points.csv', 'w')
# List of PolyLine objects
# need to get the points out of each PolyLine.
for pl in all_progress_line_entities:
for p in pl.points:
f.write('{},{},{}\n'.format(p[0],p[1],p[2]))
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment