dxf_reader.py 689 B

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