camlib.html 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Camlib &mdash; Cirkuix 0.5 documentation</title>
  8. <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT:'./',
  12. VERSION:'0.5',
  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="stylesheet" href="_static/css/theme.css" type="text/css" />
  22. <script type="text/javascript" src="_static/js/theme.js"></script>
  23. <script type="text/javascript">
  24. jQuery(function () {
  25. SphinxRtdTheme.StickyNav.enable();
  26. });
  27. </script>
  28. <link rel="top" title="Cirkuix 0.5 documentation" href="index.html"/>
  29. <link rel="next" title="FlatCAM Objects" href="flatcamobj.html"/>
  30. <link rel="prev" title="Welcome to FlatCAM’s documentation!" href="index.html"/>
  31. <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
  32. </head>
  33. <body class="wy-body-for-nav" role="document">
  34. <div class="wy-grid-for-nav">
  35. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  36. <div class="wy-side-nav-search">
  37. <a href="index.html" class="icon icon-home"> Cirkuix</a>
  38. <div role="search">
  39. <form id ="rtd-search-form" class="wy-form" action="search.html" method="get">
  40. <input type="text" name="q" placeholder="Search docs" />
  41. <input type="hidden" name="check_keywords" value="yes" />
  42. <input type="hidden" name="area" value="default" />
  43. </form>
  44. </div>
  45. </div>
  46. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  47. <ul class="current">
  48. <li class="toctree-l1 current"><a class="current reference internal" href="">Camlib</a></li>
  49. <li class="toctree-l1"><a class="reference internal" href="flatcamobj.html">FlatCAM Objects</a></li>
  50. <li class="toctree-l1"><a class="reference internal" href="app.html">FlatCAM Application</a></li>
  51. </ul>
  52. </div>
  53. &nbsp;
  54. </nav>
  55. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  56. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  57. <i data-toggle="wy-nav-top" class="icon icon-reorder"></i>
  58. <a href="index.html">Cirkuix</a>
  59. </nav>
  60. <div class="wy-nav-content">
  61. <div class="rst-content">
  62. <div role="navigation" aria-label="breadcrumbs navigation">
  63. <ul class="wy-breadcrumbs">
  64. <li><a href="index.html">Docs</a> &raquo;</li>
  65. <li>Camlib</li>
  66. <li class="wy-breadcrumbs-aside">
  67. <a href="_sources/camlib.txt" rel="nofollow"> View page source</a>
  68. </li>
  69. </ul>
  70. <hr/>
  71. </div>
  72. <div role="main">
  73. <div class="section" id="module-camlib">
  74. <span id="camlib"></span><h1>Camlib<a class="headerlink" href="#module-camlib" title="Permalink to this headline">¶</a></h1>
  75. <dl class="class">
  76. <dt id="camlib.Geometry">
  77. <em class="property">class </em><tt class="descclassname">camlib.</tt><tt class="descname">Geometry</tt><a class="headerlink" href="#camlib.Geometry" title="Permalink to this definition">¶</a></dt>
  78. <dd><dl class="method">
  79. <dt id="camlib.Geometry.bounds">
  80. <tt class="descname">bounds</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.Geometry.bounds" title="Permalink to this definition">¶</a></dt>
  81. <dd><p>Returns coordinates of rectangular bounds
  82. of geometry: (xmin, ymin, xmax, ymax).</p>
  83. </dd></dl>
  84. <dl class="method">
  85. <dt id="camlib.Geometry.clear_polygon">
  86. <tt class="descname">clear_polygon</tt><big>(</big><em>polygon</em>, <em>tooldia</em>, <em>overlap=0.15</em><big>)</big><a class="headerlink" href="#camlib.Geometry.clear_polygon" title="Permalink to this definition">¶</a></dt>
  87. <dd><p>Creates geometry inside a polygon for a tool to cover
  88. the whole area.</p>
  89. </dd></dl>
  90. <dl class="method">
  91. <dt id="camlib.Geometry.convert_units">
  92. <tt class="descname">convert_units</tt><big>(</big><em>units</em><big>)</big><a class="headerlink" href="#camlib.Geometry.convert_units" title="Permalink to this definition">¶</a></dt>
  93. <dd><p>Converts the units of the object to <tt class="docutils literal"><span class="pre">units</span></tt> by scaling all
  94. the geometry appropriately. This call <tt class="docutils literal"><span class="pre">scale()</span></tt>. Don&#8217;t call
  95. it again in descendents.</p>
  96. <table class="docutils field-list" frame="void" rules="none">
  97. <col class="field-name" />
  98. <col class="field-body" />
  99. <tbody valign="top">
  100. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>units</strong> (<em>str</em>) &#8211; &#8220;IN&#8221; or &#8220;MM&#8221;</td>
  101. </tr>
  102. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Scaling factor resulting from unit change.</td>
  103. </tr>
  104. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">float</td>
  105. </tr>
  106. </tbody>
  107. </table>
  108. </dd></dl>
  109. <dl class="method">
  110. <dt id="camlib.Geometry.from_dict">
  111. <tt class="descname">from_dict</tt><big>(</big><em>d</em><big>)</big><a class="headerlink" href="#camlib.Geometry.from_dict" title="Permalink to this definition">¶</a></dt>
  112. <dd><p>Sets object&#8217;s attributes from a dictionary.
  113. Attributes to include are listed in <tt class="docutils literal"><span class="pre">self.ser_attrs</span></tt>.
  114. This method will look only for only and all the
  115. attributes in <tt class="docutils literal"><span class="pre">self.ser_attrs</span></tt>. They must all
  116. be present. Use only for deserializing saved
  117. objects.</p>
  118. <table class="docutils field-list" frame="void" rules="none">
  119. <col class="field-name" />
  120. <col class="field-body" />
  121. <tbody valign="top">
  122. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>d</strong> (<em>dict</em>) &#8211; Dictionary of attributes to set in the object.</td>
  123. </tr>
  124. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  125. </tr>
  126. </tbody>
  127. </table>
  128. </dd></dl>
  129. <dl class="method">
  130. <dt id="camlib.Geometry.get_empty_area">
  131. <tt class="descname">get_empty_area</tt><big>(</big><em>boundary=None</em><big>)</big><a class="headerlink" href="#camlib.Geometry.get_empty_area" title="Permalink to this definition">¶</a></dt>
  132. <dd><p>Returns the complement of self.solid_geometry within
  133. the given boundary polygon. If not specified, it defaults to
  134. the rectangular bounding box of self.solid_geometry.</p>
  135. </dd></dl>
  136. <dl class="method">
  137. <dt id="camlib.Geometry.isolation_geometry">
  138. <tt class="descname">isolation_geometry</tt><big>(</big><em>offset</em><big>)</big><a class="headerlink" href="#camlib.Geometry.isolation_geometry" title="Permalink to this definition">¶</a></dt>
  139. <dd><p>Creates contours around geometry at a given
  140. offset distance.</p>
  141. <table class="docutils field-list" frame="void" rules="none">
  142. <col class="field-name" />
  143. <col class="field-body" />
  144. <tbody valign="top">
  145. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>offset</strong> (<em>float</em>) &#8211; Offset distance.</td>
  146. </tr>
  147. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The buffered geometry.</td>
  148. </tr>
  149. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">Shapely.MultiPolygon or Shapely.Polygon</td>
  150. </tr>
  151. </tbody>
  152. </table>
  153. </dd></dl>
  154. <dl class="method">
  155. <dt id="camlib.Geometry.offset">
  156. <tt class="descname">offset</tt><big>(</big><em>vect</em><big>)</big><a class="headerlink" href="#camlib.Geometry.offset" title="Permalink to this definition">¶</a></dt>
  157. <dd><p>Offset the geometry by the given vector. Override this method.</p>
  158. <table class="docutils field-list" frame="void" rules="none">
  159. <col class="field-name" />
  160. <col class="field-body" />
  161. <tbody valign="top">
  162. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>vect</strong> (<em>tuple</em>) &#8211; (x, y) vector by which to offset the object.</td>
  163. </tr>
  164. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  165. </tr>
  166. </tbody>
  167. </table>
  168. </dd></dl>
  169. <dl class="method">
  170. <dt id="camlib.Geometry.scale">
  171. <tt class="descname">scale</tt><big>(</big><em>factor</em><big>)</big><a class="headerlink" href="#camlib.Geometry.scale" title="Permalink to this definition">¶</a></dt>
  172. <dd><p>Scales all of the object&#8217;s geometry by a given factor. Override
  173. this method.
  174. :param factor: Number by which to scale.
  175. :type factor: float
  176. :return: None
  177. :rtype: None</p>
  178. </dd></dl>
  179. <dl class="method">
  180. <dt id="camlib.Geometry.size">
  181. <tt class="descname">size</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.Geometry.size" title="Permalink to this definition">¶</a></dt>
  182. <dd><p>Returns (width, height) of rectangular
  183. bounds of geometry.</p>
  184. </dd></dl>
  185. <dl class="method">
  186. <dt id="camlib.Geometry.to_dict">
  187. <tt class="descname">to_dict</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.Geometry.to_dict" title="Permalink to this definition">¶</a></dt>
  188. <dd><p>Returns a respresentation of the object as a dictionary.
  189. Attributes to include are listed in <tt class="docutils literal"><span class="pre">self.ser_attrs</span></tt>.</p>
  190. <table class="docutils field-list" frame="void" rules="none">
  191. <col class="field-name" />
  192. <col class="field-body" />
  193. <tbody valign="top">
  194. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">A dictionary-encoded copy of the object.</td>
  195. </tr>
  196. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">dict</td>
  197. </tr>
  198. </tbody>
  199. </table>
  200. </dd></dl>
  201. </dd></dl>
  202. <dl class="class">
  203. <dt id="camlib.Gerber">
  204. <em class="property">class </em><tt class="descclassname">camlib.</tt><tt class="descname">Gerber</tt><big>(</big><em>Geometry</em><big>)</big><a class="headerlink" href="#camlib.Gerber" title="Permalink to this definition">¶</a></dt>
  205. <dd><p><strong>ATTRIBUTES</strong></p>
  206. <ul class="simple">
  207. <li><tt class="docutils literal"><span class="pre">apertures</span></tt> (dict): The keys are names/identifiers of each aperture.
  208. The values are dictionaries key/value pairs which describe the aperture. The
  209. type key is always present and the rest depend on the key:</li>
  210. </ul>
  211. <table border="1" class="docutils">
  212. <colgroup>
  213. <col width="24%" />
  214. <col width="76%" />
  215. </colgroup>
  216. <thead valign="bottom">
  217. <tr class="row-odd"><th class="head">Key</th>
  218. <th class="head">Value</th>
  219. </tr>
  220. </thead>
  221. <tbody valign="top">
  222. <tr class="row-even"><td>type</td>
  223. <td>(str) &#8220;C&#8221;, &#8220;R&#8221;, or &#8220;O&#8221;</td>
  224. </tr>
  225. <tr class="row-odd"><td>others</td>
  226. <td>Depend on <tt class="docutils literal"><span class="pre">type</span></tt></td>
  227. </tr>
  228. </tbody>
  229. </table>
  230. <ul class="simple">
  231. <li><tt class="docutils literal"><span class="pre">paths</span></tt> (list): A path is described by a line an aperture that follows that
  232. line. Each paths[i] is a dictionary:</li>
  233. </ul>
  234. <table border="1" class="docutils">
  235. <colgroup>
  236. <col width="20%" />
  237. <col width="80%" />
  238. </colgroup>
  239. <thead valign="bottom">
  240. <tr class="row-odd"><th class="head">Key</th>
  241. <th class="head">Value</th>
  242. </tr>
  243. </thead>
  244. <tbody valign="top">
  245. <tr class="row-even"><td>linestring</td>
  246. <td>(Shapely.LineString) The actual path.</td>
  247. </tr>
  248. <tr class="row-odd"><td>aperture</td>
  249. <td>(str) The key for an aperture in apertures.</td>
  250. </tr>
  251. </tbody>
  252. </table>
  253. <ul class="simple">
  254. <li><tt class="docutils literal"><span class="pre">flashes</span></tt> (list): Flashes are single-point strokes of an aperture. Each
  255. is a dictionary:</li>
  256. </ul>
  257. <table border="1" class="docutils">
  258. <colgroup>
  259. <col width="20%" />
  260. <col width="80%" />
  261. </colgroup>
  262. <thead valign="bottom">
  263. <tr class="row-odd"><th class="head">Key</th>
  264. <th class="head">Value</th>
  265. </tr>
  266. </thead>
  267. <tbody valign="top">
  268. <tr class="row-even"><td>loc</td>
  269. <td>(list) [x (float), y (float)] coordinates.</td>
  270. </tr>
  271. <tr class="row-odd"><td>aperture</td>
  272. <td>(str) The key for an aperture in apertures.</td>
  273. </tr>
  274. </tbody>
  275. </table>
  276. <ul class="simple">
  277. <li><tt class="docutils literal"><span class="pre">regions</span></tt> (list): Are surfaces defined by a polygon (Shapely.Polygon),
  278. which have an exterior and zero or more interiors. An aperture is also
  279. associated with a region. Each is a dictionary:</li>
  280. </ul>
  281. <table border="1" class="docutils">
  282. <colgroup>
  283. <col width="18%" />
  284. <col width="82%" />
  285. </colgroup>
  286. <thead valign="bottom">
  287. <tr class="row-odd"><th class="head">Key</th>
  288. <th class="head">Value</th>
  289. </tr>
  290. </thead>
  291. <tbody valign="top">
  292. <tr class="row-even"><td>polygon</td>
  293. <td>(Shapely.Polygon) The polygon defining the region.</td>
  294. </tr>
  295. <tr class="row-odd"><td>aperture</td>
  296. <td>(str) The key for an aperture in apertures.</td>
  297. </tr>
  298. </tbody>
  299. </table>
  300. <ul class="simple">
  301. <li><tt class="docutils literal"><span class="pre">flash_geometry</span></tt> (list): List of (Shapely) geometric object resulting
  302. from <tt class="docutils literal"><span class="pre">flashes</span></tt>. These are generated from <tt class="docutils literal"><span class="pre">flashes</span></tt> in <tt class="docutils literal"><span class="pre">do_flashes()</span></tt>.</li>
  303. <li><tt class="docutils literal"><span class="pre">buffered_paths</span></tt> (list): List of (Shapely) polygons resulting from
  304. <em>buffering</em> (or thickening) the <tt class="docutils literal"><span class="pre">paths</span></tt> with the aperture. These are
  305. generated from <tt class="docutils literal"><span class="pre">paths</span></tt> in <tt class="docutils literal"><span class="pre">buffer_paths()</span></tt>.</li>
  306. </ul>
  307. <p><strong>USAGE</strong>:</p>
  308. <div class="highlight-python"><div class="highlight"><pre><span class="n">g</span> <span class="o">=</span> <span class="n">Gerber</span><span class="p">()</span>
  309. <span class="n">g</span><span class="o">.</span><span class="n">parse_file</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
  310. <span class="n">g</span><span class="o">.</span><span class="n">create_geometry</span><span class="p">()</span>
  311. <span class="n">do_something</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">solid_geometry</span><span class="p">)</span>
  312. </pre></div>
  313. </div>
  314. <dl class="method">
  315. <dt id="camlib.Gerber.aperture_parse">
  316. <tt class="descname">aperture_parse</tt><big>(</big><em>gline</em><big>)</big><a class="headerlink" href="#camlib.Gerber.aperture_parse" title="Permalink to this definition">¶</a></dt>
  317. <dd><p>Parse gerber aperture definition into dictionary of apertures.
  318. The following kinds and their attributes are supported:</p>
  319. <ul class="simple">
  320. <li><em>Circular (C)</em>: size (float)</li>
  321. <li><em>Rectangle (R)</em>: width (float), height (float)</li>
  322. <li><em>Obround (O)</em>: width (float), height (float).</li>
  323. </ul>
  324. <table class="docutils field-list" frame="void" rules="none">
  325. <col class="field-name" />
  326. <col class="field-body" />
  327. <tbody valign="top">
  328. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>gline</strong> (<em>str</em>) &#8211; Line of Gerber code known to have an aperture definition.</td>
  329. </tr>
  330. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Identifier of the aperture.</td>
  331. </tr>
  332. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td>
  333. </tr>
  334. </tbody>
  335. </table>
  336. </dd></dl>
  337. <dl class="method">
  338. <dt id="camlib.Gerber.buffer_paths">
  339. <tt class="descname">buffer_paths</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.Gerber.buffer_paths" title="Permalink to this definition">¶</a></dt>
  340. <dd><p>This is part of the parsing process. &#8220;Thickens&#8221; the paths
  341. by their appertures. This will only work for circular appertures.
  342. :return: None</p>
  343. </dd></dl>
  344. <dl class="method">
  345. <dt id="camlib.Gerber.create_geometry">
  346. <tt class="descname">create_geometry</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.Gerber.create_geometry" title="Permalink to this definition">¶</a></dt>
  347. <dd><p>Geometry from a Gerber file is made up entirely of polygons.
  348. Every stroke (linear or circular) has an aperture which gives
  349. it thickness. Additionally, aperture strokes have non-zero area,
  350. and regions naturally do as well.</p>
  351. <p>:rtype : None
  352. :return: None</p>
  353. </dd></dl>
  354. <dl class="method">
  355. <dt id="camlib.Gerber.do_flashes">
  356. <tt class="descname">do_flashes</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.Gerber.do_flashes" title="Permalink to this definition">¶</a></dt>
  357. <dd><p>Creates geometry for Gerber flashes (aperture on a single point).</p>
  358. </dd></dl>
  359. <dl class="method">
  360. <dt id="camlib.Gerber.fix_regions">
  361. <tt class="descname">fix_regions</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.Gerber.fix_regions" title="Permalink to this definition">¶</a></dt>
  362. <dd><p>Overwrites the region polygons with fixed
  363. versions if found to be invalid (according to Shapely).</p>
  364. </dd></dl>
  365. <dl class="attribute">
  366. <dt id="camlib.Gerber.frac_digits">
  367. <tt class="descname">frac_digits</tt><em class="property"> = None</em><a class="headerlink" href="#camlib.Gerber.frac_digits" title="Permalink to this definition">¶</a></dt>
  368. <dd><p>Number of fraction digits in Gerber numbers. Used during parsing.</p>
  369. </dd></dl>
  370. <dl class="method">
  371. <dt id="camlib.Gerber.get_bounding_box">
  372. <tt class="descname">get_bounding_box</tt><big>(</big><em>margin=0.0</em>, <em>rounded=False</em><big>)</big><a class="headerlink" href="#camlib.Gerber.get_bounding_box" title="Permalink to this definition">¶</a></dt>
  373. <dd><p>Creates and returns a rectangular polygon bounding at a distance of
  374. margin from the object&#8217;s <tt class="docutils literal"><span class="pre">solid_geometry</span></tt>. If margin &gt; 0, the polygon
  375. can optionally have rounded corners of radius equal to margin.</p>
  376. <table class="docutils field-list" frame="void" rules="none">
  377. <col class="field-name" />
  378. <col class="field-body" />
  379. <tbody valign="top">
  380. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  381. <li><strong>margin</strong> (<em>float</em>) &#8211; Distance to enlarge the rectangular bounding
  382. box in both positive and negative, x and y axes.</li>
  383. <li><strong>rounded</strong> (<em>bool</em>) &#8211; Wether or not to have rounded corners.</li>
  384. </ul>
  385. </td>
  386. </tr>
  387. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The bounding box.</p>
  388. </td>
  389. </tr>
  390. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">Shapely.Polygon</p>
  391. </td>
  392. </tr>
  393. </tbody>
  394. </table>
  395. </dd></dl>
  396. <dl class="attribute">
  397. <dt id="camlib.Gerber.int_digits">
  398. <tt class="descname">int_digits</tt><em class="property"> = None</em><a class="headerlink" href="#camlib.Gerber.int_digits" title="Permalink to this definition">¶</a></dt>
  399. <dd><p>Number of integer digits in Gerber numbers. Used during parsing.</p>
  400. </dd></dl>
  401. <dl class="method">
  402. <dt id="camlib.Gerber.offset">
  403. <tt class="descname">offset</tt><big>(</big><em>vect</em><big>)</big><a class="headerlink" href="#camlib.Gerber.offset" title="Permalink to this definition">¶</a></dt>
  404. <dd><p>Offsets the objects&#8217; geometry on the XY plane by a given vector.
  405. These are:</p>
  406. <ul class="simple">
  407. <li><tt class="docutils literal"><span class="pre">paths</span></tt></li>
  408. <li><tt class="docutils literal"><span class="pre">regions</span></tt></li>
  409. <li><tt class="docutils literal"><span class="pre">flashes</span></tt></li>
  410. </ul>
  411. <p>Then <tt class="docutils literal"><span class="pre">buffered_paths</span></tt>, <tt class="docutils literal"><span class="pre">flash_geometry</span></tt> and <tt class="docutils literal"><span class="pre">solid_geometry</span></tt>
  412. are re-created with <tt class="docutils literal"><span class="pre">self.create_geometry()</span></tt>.
  413. :param vect: (x, y) offset vector.
  414. :type vect: tuple
  415. :return: None</p>
  416. </dd></dl>
  417. <dl class="method">
  418. <dt id="camlib.Gerber.parse_file">
  419. <tt class="descname">parse_file</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#camlib.Gerber.parse_file" title="Permalink to this definition">¶</a></dt>
  420. <dd><p>Calls Gerber.parse_lines() with array of lines
  421. read from the given file.</p>
  422. </dd></dl>
  423. <dl class="method">
  424. <dt id="camlib.Gerber.parse_lines">
  425. <tt class="descname">parse_lines</tt><big>(</big><em>glines</em><big>)</big><a class="headerlink" href="#camlib.Gerber.parse_lines" title="Permalink to this definition">¶</a></dt>
  426. <dd><p>Main Gerber parser. Reads Gerber and populates <tt class="docutils literal"><span class="pre">self.paths</span></tt>, <tt class="docutils literal"><span class="pre">self.apertures</span></tt>,
  427. <tt class="docutils literal"><span class="pre">self.flashes</span></tt>, <tt class="docutils literal"><span class="pre">self.regions</span></tt> and <tt class="docutils literal"><span class="pre">self.units</span></tt>.</p>
  428. <table class="docutils field-list" frame="void" rules="none">
  429. <col class="field-name" />
  430. <col class="field-body" />
  431. <tbody valign="top">
  432. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>glines</strong> (<em>list</em>) &#8211; Gerber code as list of strings, each element being
  433. one line of the source file.</td>
  434. </tr>
  435. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  436. </tr>
  437. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td>
  438. </tr>
  439. </tbody>
  440. </table>
  441. </dd></dl>
  442. <dl class="method">
  443. <dt id="camlib.Gerber.scale">
  444. <tt class="descname">scale</tt><big>(</big><em>factor</em><big>)</big><a class="headerlink" href="#camlib.Gerber.scale" title="Permalink to this definition">¶</a></dt>
  445. <dd><p>Scales the objects&#8217; geometry on the XY plane by a given factor.
  446. These are:</p>
  447. <ul class="simple">
  448. <li><tt class="docutils literal"><span class="pre">apertures</span></tt></li>
  449. <li><tt class="docutils literal"><span class="pre">paths</span></tt></li>
  450. <li><tt class="docutils literal"><span class="pre">regions</span></tt></li>
  451. <li><tt class="docutils literal"><span class="pre">flashes</span></tt></li>
  452. </ul>
  453. <p>Then <tt class="docutils literal"><span class="pre">buffered_paths</span></tt>, <tt class="docutils literal"><span class="pre">flash_geometry</span></tt> and <tt class="docutils literal"><span class="pre">solid_geometry</span></tt>
  454. are re-created with <tt class="docutils literal"><span class="pre">self.create_geometry()</span></tt>.
  455. :param factor: Number by which to scale.
  456. :type factor: float
  457. :rtype : None</p>
  458. </dd></dl>
  459. </dd></dl>
  460. <dl class="class">
  461. <dt id="camlib.Excellon">
  462. <em class="property">class </em><tt class="descclassname">camlib.</tt><tt class="descname">Excellon</tt><a class="headerlink" href="#camlib.Excellon" title="Permalink to this definition">¶</a></dt>
  463. <dd><p><em>ATTRIBUTES</em></p>
  464. <ul class="simple">
  465. <li><tt class="docutils literal"><span class="pre">tools</span></tt> (dict): The key is the tool name and the value is
  466. the size (diameter).</li>
  467. <li><tt class="docutils literal"><span class="pre">drills</span></tt> (list): Each is a dictionary:</li>
  468. </ul>
  469. <table border="1" class="docutils">
  470. <colgroup>
  471. <col width="31%" />
  472. <col width="69%" />
  473. </colgroup>
  474. <thead valign="bottom">
  475. <tr class="row-odd"><th class="head">Key</th>
  476. <th class="head">Value</th>
  477. </tr>
  478. </thead>
  479. <tbody valign="top">
  480. <tr class="row-even"><td>point</td>
  481. <td>(Shapely.Point) Where to drill</td>
  482. </tr>
  483. <tr class="row-odd"><td>tool</td>
  484. <td>(str) A key in <tt class="docutils literal"><span class="pre">tools</span></tt></td>
  485. </tr>
  486. </tbody>
  487. </table>
  488. <dl class="method">
  489. <dt id="camlib.Excellon.offset">
  490. <tt class="descname">offset</tt><big>(</big><em>vect</em><big>)</big><a class="headerlink" href="#camlib.Excellon.offset" title="Permalink to this definition">¶</a></dt>
  491. <dd><p>Offsets geometry on the XY plane in the object by a given vector.</p>
  492. <table class="docutils field-list" frame="void" rules="none">
  493. <col class="field-name" />
  494. <col class="field-body" />
  495. <tbody valign="top">
  496. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>vect</strong> (<em>tuple</em>) &#8211; (x, y) offset vector.</td>
  497. </tr>
  498. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  499. </tr>
  500. </tbody>
  501. </table>
  502. </dd></dl>
  503. <dl class="method">
  504. <dt id="camlib.Excellon.parse_file">
  505. <tt class="descname">parse_file</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#camlib.Excellon.parse_file" title="Permalink to this definition">¶</a></dt>
  506. <dd><p>Reads the specified file as array of lines as
  507. passes it to <tt class="docutils literal"><span class="pre">parse_lines()</span></tt>.</p>
  508. <table class="docutils field-list" frame="void" rules="none">
  509. <col class="field-name" />
  510. <col class="field-body" />
  511. <tbody valign="top">
  512. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filename</strong> (<em>str</em>) &#8211; The file to be read and parsed.</td>
  513. </tr>
  514. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  515. </tr>
  516. </tbody>
  517. </table>
  518. </dd></dl>
  519. <dl class="method">
  520. <dt id="camlib.Excellon.parse_lines">
  521. <tt class="descname">parse_lines</tt><big>(</big><em>elines</em><big>)</big><a class="headerlink" href="#camlib.Excellon.parse_lines" title="Permalink to this definition">¶</a></dt>
  522. <dd><p>Main Excellon parser.</p>
  523. <table class="docutils field-list" frame="void" rules="none">
  524. <col class="field-name" />
  525. <col class="field-body" />
  526. <tbody valign="top">
  527. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>elines</strong> (<em>list</em>) &#8211; List of strings, each being a line of Excellon code.</td>
  528. </tr>
  529. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  530. </tr>
  531. </tbody>
  532. </table>
  533. </dd></dl>
  534. <dl class="method">
  535. <dt id="camlib.Excellon.scale">
  536. <tt class="descname">scale</tt><big>(</big><em>factor</em><big>)</big><a class="headerlink" href="#camlib.Excellon.scale" title="Permalink to this definition">¶</a></dt>
  537. <dd><p>Scales geometry on the XY plane in the object by a given factor.
  538. Tool sizes, feedrates an Z-plane dimensions are untouched.</p>
  539. <table class="docutils field-list" frame="void" rules="none">
  540. <col class="field-name" />
  541. <col class="field-body" />
  542. <tbody valign="top">
  543. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>factor</strong> (<em>float</em>) &#8211; Number by which to scale the object.</td>
  544. </tr>
  545. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  546. </tr>
  547. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">NOne</td>
  548. </tr>
  549. </tbody>
  550. </table>
  551. </dd></dl>
  552. </dd></dl>
  553. <dl class="class">
  554. <dt id="camlib.CNCjob">
  555. <em class="property">class </em><tt class="descclassname">camlib.</tt><tt class="descname">CNCjob</tt><big>(</big><em>units='in'</em>, <em>kind='generic'</em>, <em>z_move=0.1</em>, <em>feedrate=3.0</em>, <em>z_cut=-0.002</em>, <em>tooldia=0.0</em><big>)</big><a class="headerlink" href="#camlib.CNCjob" title="Permalink to this definition">¶</a></dt>
  556. <dd><p>Represents work to be done by a CNC machine.</p>
  557. <p><em>ATTRIBUTES</em></p>
  558. <ul class="simple">
  559. <li><tt class="docutils literal"><span class="pre">gcode_parsed</span></tt> (list): Each is a dictionary:</li>
  560. </ul>
  561. <table border="1" class="docutils">
  562. <colgroup>
  563. <col width="34%" />
  564. <col width="66%" />
  565. </colgroup>
  566. <thead valign="bottom">
  567. <tr class="row-odd"><th class="head">Key</th>
  568. <th class="head">Value</th>
  569. </tr>
  570. </thead>
  571. <tbody valign="top">
  572. <tr class="row-even"><td>geom</td>
  573. <td>(Shapely.LineString) Tool path (XY plane)</td>
  574. </tr>
  575. <tr class="row-odd"><td>kind</td>
  576. <td>(string) &#8220;AB&#8221;, A is &#8220;T&#8221; (travel) or
  577. &#8220;C&#8221; (cut). B is &#8220;F&#8221; (fast) or &#8220;S&#8221; (slow).</td>
  578. </tr>
  579. </tbody>
  580. </table>
  581. <dl class="method">
  582. <dt id="camlib.CNCjob.gcode_parse">
  583. <tt class="descname">gcode_parse</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.CNCjob.gcode_parse" title="Permalink to this definition">¶</a></dt>
  584. <dd><p>G-Code parser (from self.gcode). Generates dictionary with
  585. single-segment LineString&#8217;s and &#8220;kind&#8221; indicating cut or travel,
  586. fast or feedrate speed.</p>
  587. </dd></dl>
  588. <dl class="method">
  589. <dt id="camlib.CNCjob.generate_from_excellon">
  590. <tt class="descname">generate_from_excellon</tt><big>(</big><em>exobj</em><big>)</big><a class="headerlink" href="#camlib.CNCjob.generate_from_excellon" title="Permalink to this definition">¶</a></dt>
  591. <dd><p>Generates G-code for drilling from Excellon object.
  592. self.gcode becomes a list, each element is a
  593. different job for each tool in the excellon code.</p>
  594. </dd></dl>
  595. <dl class="method">
  596. <dt id="camlib.CNCjob.generate_from_excellon_by_tool">
  597. <tt class="descname">generate_from_excellon_by_tool</tt><big>(</big><em>exobj</em>, <em>tools='all'</em><big>)</big><a class="headerlink" href="#camlib.CNCjob.generate_from_excellon_by_tool" title="Permalink to this definition">¶</a></dt>
  598. <dd><p>Creates gcode for this object from an Excellon object
  599. for the specified tools.</p>
  600. <table class="docutils field-list" frame="void" rules="none">
  601. <col class="field-name" />
  602. <col class="field-body" />
  603. <tbody valign="top">
  604. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  605. <li><strong>exobj</strong> (<em>Excellon</em>) &#8211; Excellon object to process</li>
  606. <li><strong>tools</strong> &#8211; Comma separated tool names</li>
  607. </ul>
  608. </td>
  609. </tr>
  610. <tr class="field-even field"><th class="field-name">Type:</th><td class="field-body"><p class="first">tools: str</p>
  611. </td>
  612. </tr>
  613. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">None</p>
  614. </td>
  615. </tr>
  616. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p>
  617. </td>
  618. </tr>
  619. </tbody>
  620. </table>
  621. </dd></dl>
  622. <dl class="method">
  623. <dt id="camlib.CNCjob.generate_from_geometry">
  624. <tt class="descname">generate_from_geometry</tt><big>(</big><em>geometry</em>, <em>append=True</em>, <em>tooldia=None</em>, <em>tolerance=0</em><big>)</big><a class="headerlink" href="#camlib.CNCjob.generate_from_geometry" title="Permalink to this definition">¶</a></dt>
  625. <dd><p>Generates G-Code from a Geometry object. Stores in <tt class="docutils literal"><span class="pre">self.gcode</span></tt>.</p>
  626. <table class="docutils field-list" frame="void" rules="none">
  627. <col class="field-name" />
  628. <col class="field-body" />
  629. <tbody valign="top">
  630. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  631. <li><strong>geometry</strong> (<em>Geometry</em>) &#8211; Geometry defining the toolpath</li>
  632. <li><strong>append</strong> (<em>bool</em>) &#8211; Wether to append to self.gcode or re-write it.</li>
  633. <li><strong>tooldia</strong> (<em>bool</em>) &#8211; If given, sets the tooldia property but does
  634. not affect the process in any other way.</li>
  635. <li><strong>tolerance</strong> &#8211; All points in the simplified object will be within the
  636. tolerance distance of the original geometry.</li>
  637. </ul>
  638. </td>
  639. </tr>
  640. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">None</p>
  641. </td>
  642. </tr>
  643. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p>
  644. </td>
  645. </tr>
  646. </tbody>
  647. </table>
  648. </dd></dl>
  649. <dl class="method">
  650. <dt id="camlib.CNCjob.linear2gcode">
  651. <tt class="descname">linear2gcode</tt><big>(</big><em>linear</em>, <em>tolerance=0</em><big>)</big><a class="headerlink" href="#camlib.CNCjob.linear2gcode" title="Permalink to this definition">¶</a></dt>
  652. <dd><p>Generates G-code to cut along the linear feature.</p>
  653. <table class="docutils field-list" frame="void" rules="none">
  654. <col class="field-name" />
  655. <col class="field-body" />
  656. <tbody valign="top">
  657. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  658. <li><strong>linear</strong> &#8211; The path to cut along.</li>
  659. <li><strong>tolerance</strong> (<em>float</em>) &#8211; All points in the simplified object will be within the
  660. tolerance distance of the original geometry.</li>
  661. </ul>
  662. </td>
  663. </tr>
  664. <tr class="field-even field"><th class="field-name">Type:</th><td class="field-body"><p class="first">Shapely.LinearRing or Shapely.Linear String</p>
  665. </td>
  666. </tr>
  667. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">G-code to cut alon the linear feature.</p>
  668. </td>
  669. </tr>
  670. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
  671. </td>
  672. </tr>
  673. </tbody>
  674. </table>
  675. </dd></dl>
  676. <dl class="method">
  677. <dt id="camlib.CNCjob.offset">
  678. <tt class="descname">offset</tt><big>(</big><em>vect</em><big>)</big><a class="headerlink" href="#camlib.CNCjob.offset" title="Permalink to this definition">¶</a></dt>
  679. <dd><p>Offsets all the geometry on the XY plane in the object by the
  680. given vector.</p>
  681. <table class="docutils field-list" frame="void" rules="none">
  682. <col class="field-name" />
  683. <col class="field-body" />
  684. <tbody valign="top">
  685. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>vect</strong> (<em>tuple</em>) &#8211; (x, y) offset vector.</td>
  686. </tr>
  687. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  688. </tr>
  689. </tbody>
  690. </table>
  691. </dd></dl>
  692. <dl class="method">
  693. <dt id="camlib.CNCjob.plot2">
  694. <tt class="descname">plot2</tt><big>(</big><em>axes, tooldia=None, dpi=75, margin=0.1, color={'C': ['#5E6CFF', '#4650BD'], 'T': ['#F0E24D', '#B5AB3A']}, alpha={'C': 1.0, 'T': 0.3}, tool_tolerance=0.0005</em><big>)</big><a class="headerlink" href="#camlib.CNCjob.plot2" title="Permalink to this definition">¶</a></dt>
  695. <dd><p>Plots the G-code job onto the given axes.</p>
  696. <table class="docutils field-list" frame="void" rules="none">
  697. <col class="field-name" />
  698. <col class="field-body" />
  699. <tbody valign="top">
  700. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  701. <li><strong>axes</strong> &#8211; Matplotlib axes on which to plot.</li>
  702. <li><strong>tooldia</strong> &#8211; Tool diameter.</li>
  703. <li><strong>dpi</strong> &#8211; Not used!</li>
  704. <li><strong>margin</strong> &#8211; Not used!</li>
  705. <li><strong>color</strong> &#8211; Color specification.</li>
  706. <li><strong>alpha</strong> &#8211; Transparency specification.</li>
  707. <li><strong>tool_tolerance</strong> &#8211; Tolerance when drawing the toolshape.</li>
  708. </ul>
  709. </td>
  710. </tr>
  711. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">None</p>
  712. </td>
  713. </tr>
  714. </tbody>
  715. </table>
  716. </dd></dl>
  717. <dl class="method">
  718. <dt id="camlib.CNCjob.polygon2gcode">
  719. <tt class="descname">polygon2gcode</tt><big>(</big><em>polygon</em>, <em>tolerance=0</em><big>)</big><a class="headerlink" href="#camlib.CNCjob.polygon2gcode" title="Permalink to this definition">¶</a></dt>
  720. <dd><p>Creates G-Code for the exterior and all interior paths
  721. of a polygon.</p>
  722. <table class="docutils field-list" frame="void" rules="none">
  723. <col class="field-name" />
  724. <col class="field-body" />
  725. <tbody valign="top">
  726. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  727. <li><strong>polygon</strong> (<em>Shapely.Polygon</em>) &#8211; A Shapely.Polygon</li>
  728. <li><strong>tolerance</strong> (<em>float</em>) &#8211; All points in the simplified object will be within the
  729. tolerance distance of the original geometry.</li>
  730. </ul>
  731. </td>
  732. </tr>
  733. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">G-code to cut along polygon.</p>
  734. </td>
  735. </tr>
  736. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
  737. </td>
  738. </tr>
  739. </tbody>
  740. </table>
  741. </dd></dl>
  742. <dl class="method">
  743. <dt id="camlib.CNCjob.pre_parse">
  744. <tt class="descname">pre_parse</tt><big>(</big><em>gtext</em><big>)</big><a class="headerlink" href="#camlib.CNCjob.pre_parse" title="Permalink to this definition">¶</a></dt>
  745. <dd><p>Separates parts of the G-Code text into a list of dictionaries.
  746. Used by <tt class="docutils literal"><span class="pre">self.gcode_parse()</span></tt>.</p>
  747. <table class="docutils field-list" frame="void" rules="none">
  748. <col class="field-name" />
  749. <col class="field-body" />
  750. <tbody valign="top">
  751. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>gtext</strong> &#8211; A single string with g-code</td>
  752. </tr>
  753. </tbody>
  754. </table>
  755. </dd></dl>
  756. <dl class="method">
  757. <dt id="camlib.CNCjob.scale">
  758. <tt class="descname">scale</tt><big>(</big><em>factor</em><big>)</big><a class="headerlink" href="#camlib.CNCjob.scale" title="Permalink to this definition">¶</a></dt>
  759. <dd><p>Scales all the geometry on the XY plane in the object by the
  760. given factor. Tool sizes, feedrates, or Z-axis dimensions are
  761. not altered.</p>
  762. <table class="docutils field-list" frame="void" rules="none">
  763. <col class="field-name" />
  764. <col class="field-body" />
  765. <tbody valign="top">
  766. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>factor</strong> (<em>float</em>) &#8211; Number by which to scale the object.</td>
  767. </tr>
  768. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  769. </tr>
  770. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td>
  771. </tr>
  772. </tbody>
  773. </table>
  774. </dd></dl>
  775. </dd></dl>
  776. </div>
  777. </div>
  778. <footer>
  779. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  780. <a href="flatcamobj.html" class="btn btn-neutral float-right" title="FlatCAM Objects"/>Next <span class="icon icon-circle-arrow-right"></span></a>
  781. <a href="index.html" class="btn btn-neutral" title="Welcome to FlatCAM’s documentation!"><span class="icon icon-circle-arrow-left"></span> Previous</a>
  782. </div>
  783. <hr/>
  784. <div role="contentinfo">
  785. <p>
  786. &copy; Copyright 2014, Juan Pablo Caram.
  787. </p>
  788. </div>
  789. <a href="https://github.com/snide/sphinx_rtd_theme">Sphinx theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>
  790. </footer>
  791. </div>
  792. </div>
  793. </section>
  794. </div>
  795. </body>
  796. </html>