test_excellon_1.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Sun Jan 05 13:30:47 2014
  4. @author: jpcaram
  5. """
  6. import os
  7. os.chdir('../')
  8. from flatcamParsers.ParseGerber import *
  9. from flatcamParsers.ParseExcellon import *
  10. from matplotlib import pyplot
  11. # Gerber. To see if the Excellon is correct
  12. project_dir = "tests/gerber_files"
  13. gerber_filename = project_dir + "KiCad_Squarer-F_Cu.gtl"
  14. g = Gerber()
  15. g.parse_file(gerber_filename)
  16. g.create_geometry()
  17. excellon_filename = project_dir + "KiCad_Squarer.drl"
  18. ex = Excellon()
  19. ex.parse_file(excellon_filename)
  20. ex.create_geometry()
  21. #fig = Figure()
  22. fig = pyplot.figure()
  23. ax = fig.add_subplot(111)
  24. ax.set_aspect(1)
  25. # Plot gerber
  26. for geo in g.solid_geometry:
  27. x, y = geo.exterior.coords.xy
  28. pyplot.plot(x, y, 'k-')
  29. for ints in geo.interiors:
  30. x, y = ints.coords.xy
  31. ax.plot(x, y, 'k-')
  32. # Plot excellon
  33. for geo in ex.solid_geometry:
  34. x, y = geo.exterior.coords.xy
  35. pyplot.plot(x, y, 'r-')
  36. for ints in geo.interiors:
  37. x, y = ints.coords.xy
  38. ax.plot(x, y, 'g-')
  39. fig.show()