dxf_reader.py 656 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python
  2. from fileinput import input
  3. def printpoint(b):
  4. print(b)
  5. obj = dict(zip(b[::2], b[1::2]))
  6. if obj['0'] == 'AcDbMText':
  7. print('{}'.format(obj['100']))
  8. print('Code','Text')# header line
  9. buffer = ['0', 'fake'] # give first pass through loop something to process
  10. for line in input("GV_12.DXF"):
  11. line = line.rstrip()
  12. print(line)
  13. if line == '0': # we've started a new section, so
  14. printpoint(buffer) # handle the captured section
  15. buffer = [] # and start a new one
  16. buffer.append(line)
  17. printpoint(buffer) # buffer left over from last pass through loop