dxf_line_reader.py 878 B

12345678910111213141516171819202122232425262728293031323334
  1. def printpoint(b):
  2. print(b)
  3. obj = dict(zip(b[::2], b[1::2]))
  4. try:
  5. if obj['100'] == 'AcDbMText':
  6. print('{}'.format(obj['0']))
  7. except:
  8. pass
  9. buffer = ['0', 'fake']
  10. filepath = 'GV_12.DXF'
  11. with open(filepath,'r', errors="replace") as fp:
  12. line = fp.readline()
  13. cnt = 1
  14. #while line:
  15. #line = fp.readline()
  16. #line = line.rstrip()
  17. print(line)
  18. if line == '0': # we've started a new section, so
  19. print("Line {}: {}".format(cnt, line.strip()))
  20. #try:
  21. # printpoint(buffer) # handle the captured section
  22. #except:
  23. # print("ERROR")
  24. #buffer = [] # and start a new one
  25. #buffer.append(line)
  26. cnt += 1
  27. #f.close()
  28. #printpoint(buffer) # buffer left over from last pass through loop
  29. #https://leancrew.com/all-this/2016/12/dxf-data-extraction/