active.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Active Bugs &mdash; FlatCAM Bugs 1 documentation</title>
  7. <link rel="stylesheet" href="_static/default.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: './',
  12. VERSION: '1',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="_static/jquery.js"></script>
  19. <script type="text/javascript" src="_static/underscore.js"></script>
  20. <script type="text/javascript" src="_static/doctools.js"></script>
  21. <link rel="top" title="FlatCAM Bugs 1 documentation" href="index.html" />
  22. <link rel="next" title="Excellon Parser" href="excellonparse.html" />
  23. <link rel="prev" title="Welcome to FlatCAM Bugs’s documentation!" href="index.html" />
  24. </head>
  25. <body>
  26. <div class="related">
  27. <h3>Navigation</h3>
  28. <ul>
  29. <li class="right" style="margin-right: 10px">
  30. <a href="genindex.html" title="General Index"
  31. accesskey="I">index</a></li>
  32. <li class="right" >
  33. <a href="excellonparse.html" title="Excellon Parser"
  34. accesskey="N">next</a> |</li>
  35. <li class="right" >
  36. <a href="index.html" title="Welcome to FlatCAM Bugs’s documentation!"
  37. accesskey="P">previous</a> |</li>
  38. <li><a href="index.html">FlatCAM Bugs 1 documentation</a> &raquo;</li>
  39. </ul>
  40. </div>
  41. <div class="document">
  42. <div class="documentwrapper">
  43. <div class="bodywrapper">
  44. <div class="body">
  45. <div class="section" id="active-bugs">
  46. <h1>Active Bugs<a class="headerlink" href="#active-bugs" title="Permalink to this headline">¶</a></h1>
  47. <div class="section" id="drill-number-parsing">
  48. <h2>Drill number parsing<a class="headerlink" href="#drill-number-parsing" title="Permalink to this headline">¶</a></h2>
  49. <p>The screenshot below show the problematic file:</p>
  50. <img alt="_images/drill_parse_problem1.png" class="align-center" src="_images/drill_parse_problem1.png" />
  51. <p>The file reads:</p>
  52. <div class="highlight-python"><pre>G81
  53. M48
  54. METRIC
  55. T1C00.127
  56. T2C00.889
  57. T3C00.900
  58. T4C01.524
  59. T5C01.600
  60. T6C02.032
  61. T7C02.540
  62. %
  63. T002
  64. X03874Y08092
  65. X03874Y23333
  66. X06414Y08092
  67. X06414Y23333
  68. X08954Y08092
  69. ...
  70. T007
  71. X02664Y03518
  72. X02664Y41618
  73. X76324Y03518
  74. X76324Y41618
  75. ...</pre>
  76. </div>
  77. <p>After scaling by 10.0:</p>
  78. <img alt="_images/drill_parse_problem2.png" class="align-center" src="_images/drill_parse_problem2.png" />
  79. <p>The code involved is:</p>
  80. <div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  81. <span class="o">...</span>
  82. <span class="bp">self</span><span class="o">.</span><span class="n">zeros</span> <span class="o">=</span> <span class="s">&quot;T&quot;</span>
  83. <span class="o">...</span>
  84. <span class="k">def</span> <span class="nf">parse_number</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">number_str</span><span class="p">):</span>
  85. <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">zeros</span> <span class="o">==</span> <span class="s">&quot;L&quot;</span><span class="p">:</span>
  86. <span class="n">match</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">leadingzeros_re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">number_str</span><span class="p">)</span>
  87. <span class="k">return</span> <span class="nb">float</span><span class="p">(</span><span class="n">number_str</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="mi">10</span><span class="o">**</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">match</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span><span class="o">-</span><span class="mi">2</span><span class="o">+</span><span class="nb">len</span><span class="p">(</span><span class="n">match</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">))))</span>
  88. <span class="k">else</span><span class="p">:</span> <span class="c"># Trailing</span>
  89. <span class="k">return</span> <span class="nb">float</span><span class="p">(</span><span class="n">number_str</span><span class="p">)</span><span class="o">/</span><span class="mi">10000</span>
  90. </pre></div>
  91. </div>
  92. <p>The numbers are being divided by 10000. If &#8220;L&#8221; had been specified,
  93. the following regex would have applied:</p>
  94. <div class="highlight-python"><div class="highlight"><pre><span class="c"># Parse coordinates</span>
  95. <span class="bp">self</span><span class="o">.</span><span class="n">leadingzeros_re</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s">r&#39;^(0*)(\d*)&#39;</span><span class="p">)</span>
  96. </pre></div>
  97. </div>
  98. <p>Then the number 02664 would have been divided by 10**(4-2+1) = 10**3 = 1000,
  99. which is what is desired.</p>
  100. <p>Leading zeros weren&#8217;t specified, but www.excellon.com says:</p>
  101. <blockquote>
  102. <div>The CNC-7 uses leading zeros unless you specify
  103. otherwise through a part program or the console.</div></blockquote>
  104. <div class="admonition note">
  105. <p class="first admonition-title">Note</p>
  106. <p class="last">The parser has been modified to default to leading
  107. zeros.</p>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. <div class="sphinxsidebar">
  115. <div class="sphinxsidebarwrapper">
  116. <h3><a href="index.html">Table Of Contents</a></h3>
  117. <ul>
  118. <li><a class="reference internal" href="#">Active Bugs</a><ul>
  119. <li><a class="reference internal" href="#drill-number-parsing">Drill number parsing</a></li>
  120. </ul>
  121. </li>
  122. </ul>
  123. <h4>Previous topic</h4>
  124. <p class="topless"><a href="index.html"
  125. title="previous chapter">Welcome to FlatCAM Bugs&#8217;s documentation!</a></p>
  126. <h4>Next topic</h4>
  127. <p class="topless"><a href="excellonparse.html"
  128. title="next chapter">Excellon Parser</a></p>
  129. <h3>This Page</h3>
  130. <ul class="this-page-menu">
  131. <li><a href="_sources/active.txt"
  132. rel="nofollow">Show Source</a></li>
  133. </ul>
  134. <div id="searchbox" style="display: none">
  135. <h3>Quick search</h3>
  136. <form class="search" action="search.html" method="get">
  137. <input type="text" name="q" />
  138. <input type="submit" value="Go" />
  139. <input type="hidden" name="check_keywords" value="yes" />
  140. <input type="hidden" name="area" value="default" />
  141. </form>
  142. <p class="searchtip" style="font-size: 90%">
  143. Enter search terms or a module, class or function name.
  144. </p>
  145. </div>
  146. <script type="text/javascript">$('#searchbox').show(0);</script>
  147. </div>
  148. </div>
  149. <div class="clearer"></div>
  150. </div>
  151. <div class="related">
  152. <h3>Navigation</h3>
  153. <ul>
  154. <li class="right" style="margin-right: 10px">
  155. <a href="genindex.html" title="General Index"
  156. >index</a></li>
  157. <li class="right" >
  158. <a href="excellonparse.html" title="Excellon Parser"
  159. >next</a> |</li>
  160. <li class="right" >
  161. <a href="index.html" title="Welcome to FlatCAM Bugs’s documentation!"
  162. >previous</a> |</li>
  163. <li><a href="index.html">FlatCAM Bugs 1 documentation</a> &raquo;</li>
  164. </ul>
  165. </div>
  166. <div class="footer">
  167. &copy; Copyright 2014, Juan Pablo Caram.
  168. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.
  169. </div>
  170. </body>
  171. </html>