active.txt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. Active Bugs
  2. ===================
  3. Drill number parsing
  4. --------------------
  5. The screenshot below show the problematic file:
  6. .. image:: drill_parse_problem1.png
  7. :align: center
  8. The file reads::
  9. G81
  10. M48
  11. METRIC
  12. T1C00.127
  13. T2C00.889
  14. T3C00.900
  15. T4C01.524
  16. T5C01.600
  17. T6C02.032
  18. T7C02.540
  19. %
  20. T002
  21. X03874Y08092
  22. X03874Y23333
  23. X06414Y08092
  24. X06414Y23333
  25. X08954Y08092
  26. ...
  27. T007
  28. X02664Y03518
  29. X02664Y41618
  30. X76324Y03518
  31. X76324Y41618
  32. ...
  33. After scaling by 10.0:
  34. .. image:: drill_parse_problem2.png
  35. :align: center
  36. The code involved is:
  37. .. code-block:: python
  38. def __init__(self):
  39. ...
  40. self.zeros = "T"
  41. ...
  42. def parse_number(self, number_str):
  43. if self.zeros == "L":
  44. match = self.leadingzeros_re.search(number_str)
  45. return float(number_str)/(10**(len(match.group(2))-2+len(match.group(1))))
  46. else: # Trailing
  47. return float(number_str)/10000
  48. The numbers are being divided by 10000. If "L" had been specified,
  49. the following regex would have applied:
  50. .. code-block:: python
  51. # Parse coordinates
  52. self.leadingzeros_re = re.compile(r'^(0*)(\d*)')
  53. Then the number 02664 would have been divided by 10**(4-2+1) = 10**3 = 1000,
  54. which is what is desired.
  55. Leading zeros weren't specified, but www.excellon.com says:
  56. The CNC-7 uses leading zeros unless you specify
  57. otherwise through a part program or the console.
  58. .. note::
  59. The parser has been modified to default to leading
  60. zeros.