camlib.html 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268
  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><ul>
  49. <li class="toctree-l2"><a class="reference internal" href="#geometry">Geometry</a></li>
  50. <li class="toctree-l2"><a class="reference internal" href="#gerber">Gerber</a></li>
  51. <li class="toctree-l2"><a class="reference internal" href="#aperturemacro">ApertureMacro</a></li>
  52. <li class="toctree-l2"><a class="reference internal" href="#excellon">Excellon</a></li>
  53. <li class="toctree-l2"><a class="reference internal" href="#cncjob">CNCJob</a></li>
  54. </ul>
  55. </li>
  56. <li class="toctree-l1"><a class="reference internal" href="flatcamobj.html">FlatCAM Objects</a><ul>
  57. <li class="toctree-l2"><a class="reference internal" href="flatcamobj.html#flatcamobj">FlatCAMObj</a></li>
  58. <li class="toctree-l2"><a class="reference internal" href="flatcamobj.html#flatcamgerber">FlatCAMGerber</a></li>
  59. <li class="toctree-l2"><a class="reference internal" href="flatcamobj.html#flatcamexcellon">FlatCAMExcellon</a></li>
  60. <li class="toctree-l2"><a class="reference internal" href="flatcamobj.html#flatcamcncjob">FlatCAMCNCjob</a></li>
  61. <li class="toctree-l2"><a class="reference internal" href="flatcamobj.html#flatcamgeometry">FlatCAMGeometry</a></li>
  62. </ul>
  63. </li>
  64. <li class="toctree-l1"><a class="reference internal" href="app.html">FlatCAM Application</a><ul>
  65. <li class="toctree-l2"><a class="reference internal" href="app.html#app">App</a></li>
  66. <li class="toctree-l2"><a class="reference internal" href="app.html#plotcanvas">PlotCanvas</a></li>
  67. </ul>
  68. </li>
  69. <li class="toctree-l1"><a class="reference internal" href="devman.html">FlatCAM Developer Manual</a><ul>
  70. <li class="toctree-l2"><a class="reference internal" href="devman.html#options">Options</a></li>
  71. </ul>
  72. </li>
  73. </ul>
  74. </div>
  75. &nbsp;
  76. </nav>
  77. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  78. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  79. <i data-toggle="wy-nav-top" class="icon icon-reorder"></i>
  80. <a href="index.html">Cirkuix</a>
  81. </nav>
  82. <div class="wy-nav-content">
  83. <div class="rst-content">
  84. <div role="navigation" aria-label="breadcrumbs navigation">
  85. <ul class="wy-breadcrumbs">
  86. <li><a href="index.html">Docs</a> &raquo;</li>
  87. <li>Camlib</li>
  88. <li class="wy-breadcrumbs-aside">
  89. <a href="_sources/camlib.txt" rel="nofollow"> View page source</a>
  90. </li>
  91. </ul>
  92. <hr/>
  93. </div>
  94. <div role="main">
  95. <div class="section" id="module-camlib">
  96. <span id="camlib"></span><h1>Camlib<a class="headerlink" href="#module-camlib" title="Permalink to this headline">¶</a></h1>
  97. <div class="section" id="geometry">
  98. <h2>Geometry<a class="headerlink" href="#geometry" title="Permalink to this headline">¶</a></h2>
  99. <dl class="class">
  100. <dt id="camlib.Geometry">
  101. <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>
  102. <dd><dl class="method">
  103. <dt id="camlib.Geometry.bounds">
  104. <tt class="descname">bounds</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.Geometry.bounds" title="Permalink to this definition">¶</a></dt>
  105. <dd><p>Returns coordinates of rectangular bounds
  106. of geometry: (xmin, ymin, xmax, ymax).</p>
  107. </dd></dl>
  108. <dl class="method">
  109. <dt id="camlib.Geometry.clear_polygon">
  110. <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>
  111. <dd><p>Creates geometry inside a polygon for a tool to cover
  112. the whole area.</p>
  113. </dd></dl>
  114. <dl class="method">
  115. <dt id="camlib.Geometry.convert_units">
  116. <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>
  117. <dd><p>Converts the units of the object to <tt class="docutils literal"><span class="pre">units</span></tt> by scaling all
  118. the geometry appropriately. This call <tt class="docutils literal"><span class="pre">scale()</span></tt>. Don&#8217;t call
  119. it again in descendents.</p>
  120. <table class="docutils field-list" frame="void" rules="none">
  121. <col class="field-name" />
  122. <col class="field-body" />
  123. <tbody valign="top">
  124. <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>
  125. </tr>
  126. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Scaling factor resulting from unit change.</td>
  127. </tr>
  128. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">float</td>
  129. </tr>
  130. </tbody>
  131. </table>
  132. </dd></dl>
  133. <dl class="method">
  134. <dt id="camlib.Geometry.from_dict">
  135. <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>
  136. <dd><p>Sets object&#8217;s attributes from a dictionary.
  137. Attributes to include are listed in <tt class="docutils literal"><span class="pre">self.ser_attrs</span></tt>.
  138. This method will look only for only and all the
  139. attributes in <tt class="docutils literal"><span class="pre">self.ser_attrs</span></tt>. They must all
  140. be present. Use only for deserializing saved
  141. objects.</p>
  142. <table class="docutils field-list" frame="void" rules="none">
  143. <col class="field-name" />
  144. <col class="field-body" />
  145. <tbody valign="top">
  146. <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>
  147. </tr>
  148. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  149. </tr>
  150. </tbody>
  151. </table>
  152. </dd></dl>
  153. <dl class="method">
  154. <dt id="camlib.Geometry.get_empty_area">
  155. <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>
  156. <dd><p>Returns the complement of self.solid_geometry within
  157. the given boundary polygon. If not specified, it defaults to
  158. the rectangular bounding box of self.solid_geometry.</p>
  159. </dd></dl>
  160. <dl class="method">
  161. <dt id="camlib.Geometry.isolation_geometry">
  162. <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>
  163. <dd><p>Creates contours around geometry at a given
  164. offset distance.</p>
  165. <table class="docutils field-list" frame="void" rules="none">
  166. <col class="field-name" />
  167. <col class="field-body" />
  168. <tbody valign="top">
  169. <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>
  170. </tr>
  171. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The buffered geometry.</td>
  172. </tr>
  173. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">Shapely.MultiPolygon or Shapely.Polygon</td>
  174. </tr>
  175. </tbody>
  176. </table>
  177. </dd></dl>
  178. <dl class="method">
  179. <dt id="camlib.Geometry.offset">
  180. <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>
  181. <dd><p>Offset the geometry by the given vector. Override this method.</p>
  182. <table class="docutils field-list" frame="void" rules="none">
  183. <col class="field-name" />
  184. <col class="field-body" />
  185. <tbody valign="top">
  186. <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>
  187. </tr>
  188. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  189. </tr>
  190. </tbody>
  191. </table>
  192. </dd></dl>
  193. <dl class="method">
  194. <dt id="camlib.Geometry.scale">
  195. <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>
  196. <dd><p>Scales all of the object&#8217;s geometry by a given factor. Override
  197. this method.
  198. :param factor: Number by which to scale.
  199. :type factor: float
  200. :return: None
  201. :rtype: None</p>
  202. </dd></dl>
  203. <dl class="method">
  204. <dt id="camlib.Geometry.size">
  205. <tt class="descname">size</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.Geometry.size" title="Permalink to this definition">¶</a></dt>
  206. <dd><p>Returns (width, height) of rectangular
  207. bounds of geometry.</p>
  208. </dd></dl>
  209. <dl class="method">
  210. <dt id="camlib.Geometry.to_dict">
  211. <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>
  212. <dd><p>Returns a respresentation of the object as a dictionary.
  213. Attributes to include are listed in <tt class="docutils literal"><span class="pre">self.ser_attrs</span></tt>.</p>
  214. <table class="docutils field-list" frame="void" rules="none">
  215. <col class="field-name" />
  216. <col class="field-body" />
  217. <tbody valign="top">
  218. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">A dictionary-encoded copy of the object.</td>
  219. </tr>
  220. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">dict</td>
  221. </tr>
  222. </tbody>
  223. </table>
  224. </dd></dl>
  225. </dd></dl>
  226. </div>
  227. <div class="section" id="gerber">
  228. <h2>Gerber<a class="headerlink" href="#gerber" title="Permalink to this headline">¶</a></h2>
  229. <dl class="class">
  230. <dt id="camlib.Gerber">
  231. <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>
  232. <dd><p><strong>ATTRIBUTES</strong></p>
  233. <ul class="simple">
  234. <li><tt class="docutils literal"><span class="pre">apertures</span></tt> (dict): The keys are names/identifiers of each aperture.
  235. The values are dictionaries key/value pairs which describe the aperture. The
  236. type key is always present and the rest depend on the key:</li>
  237. </ul>
  238. <table border="1" class="docutils">
  239. <colgroup>
  240. <col width="24%" />
  241. <col width="76%" />
  242. </colgroup>
  243. <thead valign="bottom">
  244. <tr class="row-odd"><th class="head">Key</th>
  245. <th class="head">Value</th>
  246. </tr>
  247. </thead>
  248. <tbody valign="top">
  249. <tr class="row-even"><td>type</td>
  250. <td>(str) &#8220;C&#8221;, &#8220;R&#8221;, &#8220;O&#8221;, &#8220;P&#8221;, or &#8220;AP&#8221;</td>
  251. </tr>
  252. <tr class="row-odd"><td>others</td>
  253. <td>Depend on <tt class="docutils literal"><span class="pre">type</span></tt></td>
  254. </tr>
  255. </tbody>
  256. </table>
  257. <ul class="simple">
  258. <li><tt class="docutils literal"><span class="pre">paths</span></tt> (list): A path is described by a line an aperture that follows that
  259. line. Each paths[i] is a dictionary:</li>
  260. </ul>
  261. <table border="1" class="docutils">
  262. <colgroup>
  263. <col width="20%" />
  264. <col width="80%" />
  265. </colgroup>
  266. <thead valign="bottom">
  267. <tr class="row-odd"><th class="head">Key</th>
  268. <th class="head">Value</th>
  269. </tr>
  270. </thead>
  271. <tbody valign="top">
  272. <tr class="row-even"><td>linestring</td>
  273. <td>(Shapely.LineString) The actual path.</td>
  274. </tr>
  275. <tr class="row-odd"><td>aperture</td>
  276. <td>(str) The key for an aperture in apertures.</td>
  277. </tr>
  278. </tbody>
  279. </table>
  280. <ul class="simple">
  281. <li><tt class="docutils literal"><span class="pre">flashes</span></tt> (list): Flashes are single-point strokes of an aperture. Each
  282. is a dictionary:</li>
  283. </ul>
  284. <table border="1" class="docutils">
  285. <colgroup>
  286. <col width="20%" />
  287. <col width="80%" />
  288. </colgroup>
  289. <thead valign="bottom">
  290. <tr class="row-odd"><th class="head">Key</th>
  291. <th class="head">Value</th>
  292. </tr>
  293. </thead>
  294. <tbody valign="top">
  295. <tr class="row-even"><td>loc</td>
  296. <td>(Point) Shapely Point indicating location.</td>
  297. </tr>
  298. <tr class="row-odd"><td>aperture</td>
  299. <td>(str) The key for an aperture in apertures.</td>
  300. </tr>
  301. </tbody>
  302. </table>
  303. <ul class="simple">
  304. <li><tt class="docutils literal"><span class="pre">regions</span></tt> (list): Are surfaces defined by a polygon (Shapely.Polygon),
  305. which have an exterior and zero or more interiors. An aperture is also
  306. associated with a region. Each is a dictionary:</li>
  307. </ul>
  308. <table border="1" class="docutils">
  309. <colgroup>
  310. <col width="18%" />
  311. <col width="82%" />
  312. </colgroup>
  313. <thead valign="bottom">
  314. <tr class="row-odd"><th class="head">Key</th>
  315. <th class="head">Value</th>
  316. </tr>
  317. </thead>
  318. <tbody valign="top">
  319. <tr class="row-even"><td>polygon</td>
  320. <td>(Shapely.Polygon) The polygon defining the region.</td>
  321. </tr>
  322. <tr class="row-odd"><td>aperture</td>
  323. <td>(str) The key for an aperture in apertures.</td>
  324. </tr>
  325. </tbody>
  326. </table>
  327. <ul class="simple">
  328. <li><tt class="docutils literal"><span class="pre">aperture_macros</span></tt> (dictionary): Are predefined geometrical structures
  329. that can be instanciated with different parameters in an aperture
  330. definition. See <tt class="docutils literal"><span class="pre">apertures</span></tt> above. The key is the name of the macro,
  331. and the macro itself, the value, is a <tt class="docutils literal"><span class="pre">Aperture_Macro</span></tt> object.</li>
  332. <li><tt class="docutils literal"><span class="pre">flash_geometry</span></tt> (list): List of (Shapely) geometric object resulting
  333. 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>
  334. <li><tt class="docutils literal"><span class="pre">buffered_paths</span></tt> (list): List of (Shapely) polygons resulting from
  335. <em>buffering</em> (or thickening) the <tt class="docutils literal"><span class="pre">paths</span></tt> with the aperture. These are
  336. 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>
  337. </ul>
  338. <p><strong>USAGE</strong>:</p>
  339. <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>
  340. <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>
  341. <span class="n">g</span><span class="o">.</span><span class="n">create_geometry</span><span class="p">()</span>
  342. <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>
  343. </pre></div>
  344. </div>
  345. <dl class="method">
  346. <dt id="camlib.Gerber.aperture_parse">
  347. <tt class="descname">aperture_parse</tt><big>(</big><em>apertureId</em>, <em>apertureType</em>, <em>apParameters</em><big>)</big><a class="headerlink" href="#camlib.Gerber.aperture_parse" title="Permalink to this definition">¶</a></dt>
  348. <dd><p>Parse gerber aperture definition into dictionary of apertures.
  349. The following kinds and their attributes are supported:</p>
  350. <ul class="simple">
  351. <li><em>Circular (C)</em>: size (float)</li>
  352. <li><em>Rectangle (R)</em>: width (float), height (float)</li>
  353. <li><em>Obround (O)</em>: width (float), height (float).</li>
  354. <li><em>Polygon (P)</em>: diameter(float), vertices(int), [rotation(float)]</li>
  355. <li><em>Aperture Macro (AM)</em>: macro (ApertureMacro), modifiers (list)</li>
  356. </ul>
  357. <table class="docutils field-list" frame="void" rules="none">
  358. <col class="field-name" />
  359. <col class="field-body" />
  360. <tbody valign="top">
  361. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  362. <li><strong>apertureId</strong> (<em>str</em>) &#8211; Id of the aperture being defined.</li>
  363. <li><strong>apertureType</strong> (<em>str</em>) &#8211; Type of the aperture.</li>
  364. <li><strong>apParameters</strong> (<em>str</em>) &#8211; Parameters of the aperture.</li>
  365. </ul>
  366. </td>
  367. </tr>
  368. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Identifier of the aperture.</p>
  369. </td>
  370. </tr>
  371. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
  372. </td>
  373. </tr>
  374. </tbody>
  375. </table>
  376. </dd></dl>
  377. <dl class="method">
  378. <dt id="camlib.Gerber.buffer_paths">
  379. <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>
  380. <dd><p>This is part of the parsing process. &#8220;Thickens&#8221; the paths
  381. by their appertures. This will only work for circular appertures.</p>
  382. <table class="docutils field-list" frame="void" rules="none">
  383. <col class="field-name" />
  384. <col class="field-body" />
  385. <tbody valign="top">
  386. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  387. </tr>
  388. </tbody>
  389. </table>
  390. </dd></dl>
  391. <dl class="method">
  392. <dt id="camlib.Gerber.create_geometry">
  393. <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>
  394. <dd><p>Geometry from a Gerber file is made up entirely of polygons.
  395. Every stroke (linear or circular) has an aperture which gives
  396. it thickness. Additionally, aperture strokes have non-zero area,
  397. and regions naturally do as well.</p>
  398. <p>:rtype : None
  399. :return: None</p>
  400. </dd></dl>
  401. <dl class="method">
  402. <dt id="camlib.Gerber.do_flashes">
  403. <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>
  404. <dd><p>Creates geometry for Gerber flashes (aperture on a single point).</p>
  405. </dd></dl>
  406. <dl class="method">
  407. <dt id="camlib.Gerber.fix_regions">
  408. <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>
  409. <dd><p>Overwrites the region polygons with fixed
  410. versions if found to be invalid (according to Shapely).</p>
  411. <table class="docutils field-list" frame="void" rules="none">
  412. <col class="field-name" />
  413. <col class="field-body" />
  414. <tbody valign="top">
  415. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  416. </tr>
  417. </tbody>
  418. </table>
  419. </dd></dl>
  420. <dl class="attribute">
  421. <dt id="camlib.Gerber.frac_digits">
  422. <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>
  423. <dd><p>Number of fraction digits in Gerber numbers. Used during parsing.</p>
  424. </dd></dl>
  425. <dl class="method">
  426. <dt id="camlib.Gerber.get_bounding_box">
  427. <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>
  428. <dd><p>Creates and returns a rectangular polygon bounding at a distance of
  429. margin from the object&#8217;s <tt class="docutils literal"><span class="pre">solid_geometry</span></tt>. If margin &gt; 0, the polygon
  430. can optionally have rounded corners of radius equal to margin.</p>
  431. <table class="docutils field-list" frame="void" rules="none">
  432. <col class="field-name" />
  433. <col class="field-body" />
  434. <tbody valign="top">
  435. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  436. <li><strong>margin</strong> (<em>float</em>) &#8211; Distance to enlarge the rectangular bounding
  437. box in both positive and negative, x and y axes.</li>
  438. <li><strong>rounded</strong> (<em>bool</em>) &#8211; Wether or not to have rounded corners.</li>
  439. </ul>
  440. </td>
  441. </tr>
  442. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The bounding box.</p>
  443. </td>
  444. </tr>
  445. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">Shapely.Polygon</p>
  446. </td>
  447. </tr>
  448. </tbody>
  449. </table>
  450. </dd></dl>
  451. <dl class="attribute">
  452. <dt id="camlib.Gerber.int_digits">
  453. <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>
  454. <dd><p>Number of integer digits in Gerber numbers. Used during parsing.</p>
  455. </dd></dl>
  456. <dl class="method">
  457. <dt id="camlib.Gerber.mirror">
  458. <tt class="descname">mirror</tt><big>(</big><em>axis</em>, <em>point</em><big>)</big><a class="headerlink" href="#camlib.Gerber.mirror" title="Permalink to this definition">¶</a></dt>
  459. <dd><table class="docutils field-list" frame="void" rules="none">
  460. <col class="field-name" />
  461. <col class="field-body" />
  462. <tbody valign="top">
  463. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  464. <li><strong>axis</strong> (<em>str</em>) &#8211; &#8220;X&#8221; or &#8220;Y&#8221; indicates around which axis to mirror.</li>
  465. <li><strong>point</strong> (<em>list</em>) &#8211; [x, y] point belonging to the mirror axis.</li>
  466. </ul>
  467. </td>
  468. </tr>
  469. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">None</p>
  470. </td>
  471. </tr>
  472. </tbody>
  473. </table>
  474. </dd></dl>
  475. <dl class="method">
  476. <dt id="camlib.Gerber.offset">
  477. <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>
  478. <dd><p>Offsets the objects&#8217; geometry on the XY plane by a given vector.
  479. These are:</p>
  480. <ul class="simple">
  481. <li><tt class="docutils literal"><span class="pre">paths</span></tt></li>
  482. <li><tt class="docutils literal"><span class="pre">regions</span></tt></li>
  483. <li><tt class="docutils literal"><span class="pre">flashes</span></tt></li>
  484. </ul>
  485. <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>
  486. are re-created with <tt class="docutils literal"><span class="pre">self.create_geometry()</span></tt>.</p>
  487. <table class="docutils field-list" frame="void" rules="none">
  488. <col class="field-name" />
  489. <col class="field-body" />
  490. <tbody valign="top">
  491. <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>
  492. </tr>
  493. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  494. </tr>
  495. </tbody>
  496. </table>
  497. </dd></dl>
  498. <dl class="method">
  499. <dt id="camlib.Gerber.parse_file">
  500. <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>
  501. <dd><p>Calls Gerber.parse_lines() with array of lines
  502. read from the given file.</p>
  503. <table class="docutils field-list" frame="void" rules="none">
  504. <col class="field-name" />
  505. <col class="field-body" />
  506. <tbody valign="top">
  507. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filename</strong> (<em>str</em>) &#8211; Gerber file to parse.</td>
  508. </tr>
  509. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  510. </tr>
  511. </tbody>
  512. </table>
  513. </dd></dl>
  514. <dl class="method">
  515. <dt id="camlib.Gerber.parse_lines">
  516. <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>
  517. <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>,
  518. <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>
  519. <table class="docutils field-list" frame="void" rules="none">
  520. <col class="field-name" />
  521. <col class="field-body" />
  522. <tbody valign="top">
  523. <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
  524. one line of the source file.</td>
  525. </tr>
  526. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  527. </tr>
  528. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td>
  529. </tr>
  530. </tbody>
  531. </table>
  532. </dd></dl>
  533. <dl class="method">
  534. <dt id="camlib.Gerber.scale">
  535. <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>
  536. <dd><p>Scales the objects&#8217; geometry on the XY plane by a given factor.
  537. These are:</p>
  538. <ul class="simple">
  539. <li><tt class="docutils literal"><span class="pre">apertures</span></tt></li>
  540. <li><tt class="docutils literal"><span class="pre">paths</span></tt></li>
  541. <li><tt class="docutils literal"><span class="pre">regions</span></tt></li>
  542. <li><tt class="docutils literal"><span class="pre">flashes</span></tt></li>
  543. </ul>
  544. <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>
  545. are re-created with <tt class="docutils literal"><span class="pre">self.create_geometry()</span></tt>.
  546. :param factor: Number by which to scale.
  547. :type factor: float
  548. :rtype : None</p>
  549. </dd></dl>
  550. </dd></dl>
  551. </div>
  552. <div class="section" id="aperturemacro">
  553. <h2>ApertureMacro<a class="headerlink" href="#aperturemacro" title="Permalink to this headline">¶</a></h2>
  554. <dl class="class">
  555. <dt id="camlib.ApertureMacro">
  556. <em class="property">class </em><tt class="descclassname">camlib.</tt><tt class="descname">ApertureMacro</tt><big>(</big><em>name=None</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro" title="Permalink to this definition">¶</a></dt>
  557. <dd><dl class="method">
  558. <dt id="camlib.ApertureMacro.append">
  559. <tt class="descname">append</tt><big>(</big><em>data</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.append" title="Permalink to this definition">¶</a></dt>
  560. <dd><p>Appends a string to the raw macro.</p>
  561. <table class="docutils field-list" frame="void" rules="none">
  562. <col class="field-name" />
  563. <col class="field-body" />
  564. <tbody valign="top">
  565. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> (<em>str</em>) &#8211; Part of the macro.</td>
  566. </tr>
  567. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  568. </tr>
  569. </tbody>
  570. </table>
  571. </dd></dl>
  572. <dl class="staticmethod">
  573. <dt id="camlib.ApertureMacro.default2zero">
  574. <em class="property">static </em><tt class="descname">default2zero</tt><big>(</big><em>n</em>, <em>mods</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.default2zero" title="Permalink to this definition">¶</a></dt>
  575. <dd><p>Pads the <tt class="docutils literal"><span class="pre">mods</span></tt> list with zeros resulting in an
  576. list of length n.</p>
  577. <table class="docutils field-list" frame="void" rules="none">
  578. <col class="field-name" />
  579. <col class="field-body" />
  580. <tbody valign="top">
  581. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  582. <li><strong>n</strong> (<em>int</em>) &#8211; Length of the resulting list.</li>
  583. <li><strong>mods</strong> (<em>list</em>) &#8211; List to be padded.</li>
  584. </ul>
  585. </td>
  586. </tr>
  587. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Zero-padded list.</p>
  588. </td>
  589. </tr>
  590. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p>
  591. </td>
  592. </tr>
  593. </tbody>
  594. </table>
  595. </dd></dl>
  596. <dl class="staticmethod">
  597. <dt id="camlib.ApertureMacro.make_centerline">
  598. <em class="property">static </em><tt class="descname">make_centerline</tt><big>(</big><em>mods</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.make_centerline" title="Permalink to this definition">¶</a></dt>
  599. <dd><table class="docutils field-list" frame="void" rules="none">
  600. <col class="field-name" />
  601. <col class="field-body" />
  602. <tbody valign="top">
  603. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mods</strong> &#8211; (Exposure 0/1, width &gt;=0, height &gt;=0, x-center, y-center,
  604. rotation angle around origin in degrees)</td>
  605. </tr>
  606. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td>
  607. </tr>
  608. </tbody>
  609. </table>
  610. </dd></dl>
  611. <dl class="staticmethod">
  612. <dt id="camlib.ApertureMacro.make_circle">
  613. <em class="property">static </em><tt class="descname">make_circle</tt><big>(</big><em>mods</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.make_circle" title="Permalink to this definition">¶</a></dt>
  614. <dd><table class="docutils field-list" frame="void" rules="none">
  615. <col class="field-name" />
  616. <col class="field-body" />
  617. <tbody valign="top">
  618. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mods</strong> &#8211; (Exposure 0/1, Diameter &gt;=0, X-coord, Y-coord)</td>
  619. </tr>
  620. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td>
  621. </tr>
  622. </tbody>
  623. </table>
  624. </dd></dl>
  625. <dl class="method">
  626. <dt id="camlib.ApertureMacro.make_geometry">
  627. <tt class="descname">make_geometry</tt><big>(</big><em>modifiers</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.make_geometry" title="Permalink to this definition">¶</a></dt>
  628. <dd><p>Runs the macro for the given modifiers and generates
  629. the corresponding geometry.</p>
  630. <table class="docutils field-list" frame="void" rules="none">
  631. <col class="field-name" />
  632. <col class="field-body" />
  633. <tbody valign="top">
  634. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>modifiers</strong> (<em>list</em>) &#8211; Modifiers (parameters) for this macro</td>
  635. </tr>
  636. </tbody>
  637. </table>
  638. </dd></dl>
  639. <dl class="staticmethod">
  640. <dt id="camlib.ApertureMacro.make_lowerleftline">
  641. <em class="property">static </em><tt class="descname">make_lowerleftline</tt><big>(</big><em>mods</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.make_lowerleftline" title="Permalink to this definition">¶</a></dt>
  642. <dd><table class="docutils field-list" frame="void" rules="none">
  643. <col class="field-name" />
  644. <col class="field-body" />
  645. <tbody valign="top">
  646. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mods</strong> &#8211; (exposure 0/1, width &gt;=0, height &gt;=0, x-lowerleft, y-lowerleft,
  647. rotation angle around origin in degrees)</td>
  648. </tr>
  649. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td>
  650. </tr>
  651. </tbody>
  652. </table>
  653. </dd></dl>
  654. <dl class="staticmethod">
  655. <dt id="camlib.ApertureMacro.make_moire">
  656. <em class="property">static </em><tt class="descname">make_moire</tt><big>(</big><em>mods</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.make_moire" title="Permalink to this definition">¶</a></dt>
  657. <dd><p>Note: Specs indicate that rotation is only allowed if the center
  658. (x, y) == (0, 0). I will tolerate breaking this rule.</p>
  659. <table class="docutils field-list" frame="void" rules="none">
  660. <col class="field-name" />
  661. <col class="field-body" />
  662. <tbody valign="top">
  663. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mods</strong> &#8211; (x-center, y-center, outer_dia_outer_ring, ring thickness,
  664. gap, max_rings, crosshair_thickness, crosshair_len, rotation
  665. angle around origin in degrees)</td>
  666. </tr>
  667. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td>
  668. </tr>
  669. </tbody>
  670. </table>
  671. </dd></dl>
  672. <dl class="staticmethod">
  673. <dt id="camlib.ApertureMacro.make_outline">
  674. <em class="property">static </em><tt class="descname">make_outline</tt><big>(</big><em>mods</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.make_outline" title="Permalink to this definition">¶</a></dt>
  675. <dd><table class="docutils field-list" frame="void" rules="none">
  676. <col class="field-name" />
  677. <col class="field-body" />
  678. <tbody valign="top">
  679. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mods</strong> &#8211; </td>
  680. </tr>
  681. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td>
  682. </tr>
  683. </tbody>
  684. </table>
  685. </dd></dl>
  686. <dl class="staticmethod">
  687. <dt id="camlib.ApertureMacro.make_polygon">
  688. <em class="property">static </em><tt class="descname">make_polygon</tt><big>(</big><em>mods</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.make_polygon" title="Permalink to this definition">¶</a></dt>
  689. <dd><p>Note: Specs indicate that rotation is only allowed if the center
  690. (x, y) == (0, 0). I will tolerate breaking this rule.</p>
  691. <table class="docutils field-list" frame="void" rules="none">
  692. <col class="field-name" />
  693. <col class="field-body" />
  694. <tbody valign="top">
  695. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mods</strong> &#8211; (exposure 0/1, n_verts 3&lt;=n&lt;=12, x-center, y-center,
  696. diameter of circumscribed circle &gt;=0, rotation angle around origin)</td>
  697. </tr>
  698. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td>
  699. </tr>
  700. </tbody>
  701. </table>
  702. </dd></dl>
  703. <dl class="staticmethod">
  704. <dt id="camlib.ApertureMacro.make_thermal">
  705. <em class="property">static </em><tt class="descname">make_thermal</tt><big>(</big><em>mods</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.make_thermal" title="Permalink to this definition">¶</a></dt>
  706. <dd><p>Note: Specs indicate that rotation is only allowed if the center
  707. (x, y) == (0, 0). I will tolerate breaking this rule.</p>
  708. <table class="docutils field-list" frame="void" rules="none">
  709. <col class="field-name" />
  710. <col class="field-body" />
  711. <tbody valign="top">
  712. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mods</strong> &#8211; [x-center, y-center, diameter-outside, diameter-inside,
  713. gap-thickness, rotation angle around origin]</td>
  714. </tr>
  715. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td>
  716. </tr>
  717. </tbody>
  718. </table>
  719. </dd></dl>
  720. <dl class="staticmethod">
  721. <dt id="camlib.ApertureMacro.make_vectorline">
  722. <em class="property">static </em><tt class="descname">make_vectorline</tt><big>(</big><em>mods</em><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.make_vectorline" title="Permalink to this definition">¶</a></dt>
  723. <dd><table class="docutils field-list" frame="void" rules="none">
  724. <col class="field-name" />
  725. <col class="field-body" />
  726. <tbody valign="top">
  727. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mods</strong> &#8211; (Exposure 0/1, Line width &gt;= 0, X-start, Y-start, X-end, Y-end,
  728. rotation angle around origin in degrees)</td>
  729. </tr>
  730. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td>
  731. </tr>
  732. </tbody>
  733. </table>
  734. </dd></dl>
  735. <dl class="method">
  736. <dt id="camlib.ApertureMacro.parse_content">
  737. <tt class="descname">parse_content</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.ApertureMacro.parse_content" title="Permalink to this definition">¶</a></dt>
  738. <dd><p>Creates numerical lists for all primitives in the aperture
  739. macro (in <tt class="docutils literal"><span class="pre">self.raw</span></tt>) by replacing all variables by their
  740. values iteratively and evaluating expressions. Results
  741. are stored in <tt class="docutils literal"><span class="pre">self.primitives</span></tt>.</p>
  742. <table class="docutils field-list" frame="void" rules="none">
  743. <col class="field-name" />
  744. <col class="field-body" />
  745. <tbody valign="top">
  746. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  747. </tr>
  748. </tbody>
  749. </table>
  750. </dd></dl>
  751. </dd></dl>
  752. </div>
  753. <div class="section" id="excellon">
  754. <h2>Excellon<a class="headerlink" href="#excellon" title="Permalink to this headline">¶</a></h2>
  755. <dl class="class">
  756. <dt id="camlib.Excellon">
  757. <em class="property">class </em><tt class="descclassname">camlib.</tt><tt class="descname">Excellon</tt><big>(</big><em>Geometry</em><big>)</big><a class="headerlink" href="#camlib.Excellon" title="Permalink to this definition">¶</a></dt>
  758. <dd><p><em>ATTRIBUTES</em></p>
  759. <ul class="simple">
  760. <li><tt class="docutils literal"><span class="pre">tools</span></tt> (dict): The key is the tool name and the value is
  761. a dictionary specifying the tool:</li>
  762. </ul>
  763. <table border="1" class="docutils">
  764. <colgroup>
  765. <col width="31%" />
  766. <col width="69%" />
  767. </colgroup>
  768. <thead valign="bottom">
  769. <tr class="row-odd"><th class="head">Key</th>
  770. <th class="head">Value</th>
  771. </tr>
  772. </thead>
  773. <tbody valign="top">
  774. <tr class="row-even"><td>C</td>
  775. <td>Diameter of the tool</td>
  776. </tr>
  777. <tr class="row-odd"><td>Others</td>
  778. <td>Not supported (Ignored).</td>
  779. </tr>
  780. </tbody>
  781. </table>
  782. <ul class="simple">
  783. <li><tt class="docutils literal"><span class="pre">drills</span></tt> (list): Each is a dictionary:</li>
  784. </ul>
  785. <table border="1" class="docutils">
  786. <colgroup>
  787. <col width="31%" />
  788. <col width="69%" />
  789. </colgroup>
  790. <thead valign="bottom">
  791. <tr class="row-odd"><th class="head">Key</th>
  792. <th class="head">Value</th>
  793. </tr>
  794. </thead>
  795. <tbody valign="top">
  796. <tr class="row-even"><td>point</td>
  797. <td>(Shapely.Point) Where to drill</td>
  798. </tr>
  799. <tr class="row-odd"><td>tool</td>
  800. <td>(str) A key in <tt class="docutils literal"><span class="pre">tools</span></tt></td>
  801. </tr>
  802. </tbody>
  803. </table>
  804. <dl class="method">
  805. <dt id="camlib.Excellon.create_geometry">
  806. <tt class="descname">create_geometry</tt><big>(</big><big>)</big><a class="headerlink" href="#camlib.Excellon.create_geometry" title="Permalink to this definition">¶</a></dt>
  807. <dd><p>Creates circles of the tool diameter at every point
  808. specified in <tt class="docutils literal"><span class="pre">self.drills</span></tt>.</p>
  809. <table class="docutils field-list" frame="void" rules="none">
  810. <col class="field-name" />
  811. <col class="field-body" />
  812. <tbody valign="top">
  813. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  814. </tr>
  815. </tbody>
  816. </table>
  817. </dd></dl>
  818. <dl class="method">
  819. <dt id="camlib.Excellon.mirror">
  820. <tt class="descname">mirror</tt><big>(</big><em>axis</em>, <em>point</em><big>)</big><a class="headerlink" href="#camlib.Excellon.mirror" title="Permalink to this definition">¶</a></dt>
  821. <dd><table class="docutils field-list" frame="void" rules="none">
  822. <col class="field-name" />
  823. <col class="field-body" />
  824. <tbody valign="top">
  825. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  826. <li><strong>axis</strong> (<em>str</em>) &#8211; &#8220;X&#8221; or &#8220;Y&#8221; indicates around which axis to mirror.</li>
  827. <li><strong>point</strong> (<em>list</em>) &#8211; [x, y] point belonging to the mirror axis.</li>
  828. </ul>
  829. </td>
  830. </tr>
  831. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">None</p>
  832. </td>
  833. </tr>
  834. </tbody>
  835. </table>
  836. </dd></dl>
  837. <dl class="method">
  838. <dt id="camlib.Excellon.offset">
  839. <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>
  840. <dd><p>Offsets geometry on the XY plane in the object by a given vector.</p>
  841. <table class="docutils field-list" frame="void" rules="none">
  842. <col class="field-name" />
  843. <col class="field-body" />
  844. <tbody valign="top">
  845. <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>
  846. </tr>
  847. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  848. </tr>
  849. </tbody>
  850. </table>
  851. </dd></dl>
  852. <dl class="method">
  853. <dt id="camlib.Excellon.parse_file">
  854. <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>
  855. <dd><p>Reads the specified file as array of lines as
  856. passes it to <tt class="docutils literal"><span class="pre">parse_lines()</span></tt>.</p>
  857. <table class="docutils field-list" frame="void" rules="none">
  858. <col class="field-name" />
  859. <col class="field-body" />
  860. <tbody valign="top">
  861. <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>
  862. </tr>
  863. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  864. </tr>
  865. </tbody>
  866. </table>
  867. </dd></dl>
  868. <dl class="method">
  869. <dt id="camlib.Excellon.parse_lines">
  870. <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>
  871. <dd><p>Main Excellon parser.</p>
  872. <table class="docutils field-list" frame="void" rules="none">
  873. <col class="field-name" />
  874. <col class="field-body" />
  875. <tbody valign="top">
  876. <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>
  877. </tr>
  878. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  879. </tr>
  880. </tbody>
  881. </table>
  882. </dd></dl>
  883. <dl class="method">
  884. <dt id="camlib.Excellon.scale">
  885. <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>
  886. <dd><p>Scales geometry on the XY plane in the object by a given factor.
  887. Tool sizes, feedrates an Z-plane dimensions are untouched.</p>
  888. <table class="docutils field-list" frame="void" rules="none">
  889. <col class="field-name" />
  890. <col class="field-body" />
  891. <tbody valign="top">
  892. <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>
  893. </tr>
  894. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  895. </tr>
  896. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">NOne</td>
  897. </tr>
  898. </tbody>
  899. </table>
  900. </dd></dl>
  901. </dd></dl>
  902. </div>
  903. <div class="section" id="cncjob">
  904. <h2>CNCJob<a class="headerlink" href="#cncjob" title="Permalink to this headline">¶</a></h2>
  905. <dl class="class">
  906. <dt id="camlib.CNCjob">
  907. <em class="property">class </em><tt class="descclassname">camlib.</tt><tt class="descname">CNCjob</tt><big>(</big><em>Geometry</em><big>)</big><a class="headerlink" href="#camlib.CNCjob" title="Permalink to this definition">¶</a></dt>
  908. <dd><p>Represents work to be done by a CNC machine.</p>
  909. <p><em>ATTRIBUTES</em></p>
  910. <ul class="simple">
  911. <li><tt class="docutils literal"><span class="pre">gcode_parsed</span></tt> (list): Each is a dictionary:</li>
  912. </ul>
  913. <table border="1" class="docutils">
  914. <colgroup>
  915. <col width="34%" />
  916. <col width="66%" />
  917. </colgroup>
  918. <thead valign="bottom">
  919. <tr class="row-odd"><th class="head">Key</th>
  920. <th class="head">Value</th>
  921. </tr>
  922. </thead>
  923. <tbody valign="top">
  924. <tr class="row-even"><td>geom</td>
  925. <td>(Shapely.LineString) Tool path (XY plane)</td>
  926. </tr>
  927. <tr class="row-odd"><td>kind</td>
  928. <td>(string) &#8220;AB&#8221;, A is &#8220;T&#8221; (travel) or
  929. &#8220;C&#8221; (cut). B is &#8220;F&#8221; (fast) or &#8220;S&#8221; (slow).</td>
  930. </tr>
  931. </tbody>
  932. </table>
  933. <dl class="method">
  934. <dt id="camlib.CNCjob.gcode_parse">
  935. <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>
  936. <dd><p>G-Code parser (from self.gcode). Generates dictionary with
  937. single-segment LineString&#8217;s and &#8220;kind&#8221; indicating cut or travel,
  938. fast or feedrate speed.</p>
  939. </dd></dl>
  940. <dl class="method">
  941. <dt id="camlib.CNCjob.generate_from_excellon">
  942. <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>
  943. <dd><p>Generates G-code for drilling from Excellon object.
  944. self.gcode becomes a list, each element is a
  945. different job for each tool in the excellon code.</p>
  946. </dd></dl>
  947. <dl class="method">
  948. <dt id="camlib.CNCjob.generate_from_excellon_by_tool">
  949. <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>
  950. <dd><p>Creates gcode for this object from an Excellon object
  951. for the specified tools.</p>
  952. <table class="docutils field-list" frame="void" rules="none">
  953. <col class="field-name" />
  954. <col class="field-body" />
  955. <tbody valign="top">
  956. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  957. <li><strong>exobj</strong> (<em>Excellon</em>) &#8211; Excellon object to process</li>
  958. <li><strong>tools</strong> &#8211; Comma separated tool names</li>
  959. </ul>
  960. </td>
  961. </tr>
  962. <tr class="field-even field"><th class="field-name">Type:</th><td class="field-body"><p class="first">tools: str</p>
  963. </td>
  964. </tr>
  965. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">None</p>
  966. </td>
  967. </tr>
  968. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p>
  969. </td>
  970. </tr>
  971. </tbody>
  972. </table>
  973. </dd></dl>
  974. <dl class="method">
  975. <dt id="camlib.CNCjob.generate_from_geometry">
  976. <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>
  977. <dd><p>Generates G-Code from a Geometry object. Stores in <tt class="docutils literal"><span class="pre">self.gcode</span></tt>.</p>
  978. <table class="docutils field-list" frame="void" rules="none">
  979. <col class="field-name" />
  980. <col class="field-body" />
  981. <tbody valign="top">
  982. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  983. <li><strong>geometry</strong> (<em>Geometry</em>) &#8211; Geometry defining the toolpath</li>
  984. <li><strong>append</strong> (<em>bool</em>) &#8211; Wether to append to self.gcode or re-write it.</li>
  985. <li><strong>tooldia</strong> (<em>bool</em>) &#8211; If given, sets the tooldia property but does
  986. not affect the process in any other way.</li>
  987. <li><strong>tolerance</strong> &#8211; All points in the simplified object will be within the
  988. tolerance distance of the original geometry.</li>
  989. </ul>
  990. </td>
  991. </tr>
  992. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">None</p>
  993. </td>
  994. </tr>
  995. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p>
  996. </td>
  997. </tr>
  998. </tbody>
  999. </table>
  1000. </dd></dl>
  1001. <dl class="method">
  1002. <dt id="camlib.CNCjob.linear2gcode">
  1003. <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>
  1004. <dd><p>Generates G-code to cut along the linear feature.</p>
  1005. <table class="docutils field-list" frame="void" rules="none">
  1006. <col class="field-name" />
  1007. <col class="field-body" />
  1008. <tbody valign="top">
  1009. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1010. <li><strong>linear</strong> &#8211; The path to cut along.</li>
  1011. <li><strong>tolerance</strong> (<em>float</em>) &#8211; All points in the simplified object will be within the
  1012. tolerance distance of the original geometry.</li>
  1013. </ul>
  1014. </td>
  1015. </tr>
  1016. <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>
  1017. </td>
  1018. </tr>
  1019. <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>
  1020. </td>
  1021. </tr>
  1022. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
  1023. </td>
  1024. </tr>
  1025. </tbody>
  1026. </table>
  1027. </dd></dl>
  1028. <dl class="method">
  1029. <dt id="camlib.CNCjob.offset">
  1030. <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>
  1031. <dd><p>Offsets all the geometry on the XY plane in the object by the
  1032. given vector.</p>
  1033. <table class="docutils field-list" frame="void" rules="none">
  1034. <col class="field-name" />
  1035. <col class="field-body" />
  1036. <tbody valign="top">
  1037. <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>
  1038. </tr>
  1039. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  1040. </tr>
  1041. </tbody>
  1042. </table>
  1043. </dd></dl>
  1044. <dl class="method">
  1045. <dt id="camlib.CNCjob.plot2">
  1046. <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>
  1047. <dd><p>Plots the G-code job onto the given axes.</p>
  1048. <table class="docutils field-list" frame="void" rules="none">
  1049. <col class="field-name" />
  1050. <col class="field-body" />
  1051. <tbody valign="top">
  1052. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1053. <li><strong>axes</strong> &#8211; Matplotlib axes on which to plot.</li>
  1054. <li><strong>tooldia</strong> &#8211; Tool diameter.</li>
  1055. <li><strong>dpi</strong> &#8211; Not used!</li>
  1056. <li><strong>margin</strong> &#8211; Not used!</li>
  1057. <li><strong>color</strong> &#8211; Color specification.</li>
  1058. <li><strong>alpha</strong> &#8211; Transparency specification.</li>
  1059. <li><strong>tool_tolerance</strong> &#8211; Tolerance when drawing the toolshape.</li>
  1060. </ul>
  1061. </td>
  1062. </tr>
  1063. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">None</p>
  1064. </td>
  1065. </tr>
  1066. </tbody>
  1067. </table>
  1068. </dd></dl>
  1069. <dl class="method">
  1070. <dt id="camlib.CNCjob.polygon2gcode">
  1071. <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>
  1072. <dd><p>Creates G-Code for the exterior and all interior paths
  1073. of a polygon.</p>
  1074. <table class="docutils field-list" frame="void" rules="none">
  1075. <col class="field-name" />
  1076. <col class="field-body" />
  1077. <tbody valign="top">
  1078. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1079. <li><strong>polygon</strong> (<em>Shapely.Polygon</em>) &#8211; A Shapely.Polygon</li>
  1080. <li><strong>tolerance</strong> (<em>float</em>) &#8211; All points in the simplified object will be within the
  1081. tolerance distance of the original geometry.</li>
  1082. </ul>
  1083. </td>
  1084. </tr>
  1085. <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>
  1086. </td>
  1087. </tr>
  1088. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
  1089. </td>
  1090. </tr>
  1091. </tbody>
  1092. </table>
  1093. </dd></dl>
  1094. <dl class="method">
  1095. <dt id="camlib.CNCjob.pre_parse">
  1096. <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>
  1097. <dd><p>Separates parts of the G-Code text into a list of dictionaries.
  1098. Used by <tt class="docutils literal"><span class="pre">self.gcode_parse()</span></tt>.</p>
  1099. <table class="docutils field-list" frame="void" rules="none">
  1100. <col class="field-name" />
  1101. <col class="field-body" />
  1102. <tbody valign="top">
  1103. <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>
  1104. </tr>
  1105. </tbody>
  1106. </table>
  1107. </dd></dl>
  1108. <dl class="method">
  1109. <dt id="camlib.CNCjob.scale">
  1110. <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>
  1111. <dd><p>Scales all the geometry on the XY plane in the object by the
  1112. given factor. Tool sizes, feedrates, or Z-axis dimensions are
  1113. not altered.</p>
  1114. <table class="docutils field-list" frame="void" rules="none">
  1115. <col class="field-name" />
  1116. <col class="field-body" />
  1117. <tbody valign="top">
  1118. <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>
  1119. </tr>
  1120. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td>
  1121. </tr>
  1122. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td>
  1123. </tr>
  1124. </tbody>
  1125. </table>
  1126. </dd></dl>
  1127. </dd></dl>
  1128. </div>
  1129. </div>
  1130. </div>
  1131. <footer>
  1132. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  1133. <a href="flatcamobj.html" class="btn btn-neutral float-right" title="FlatCAM Objects"/>Next <span class="icon icon-circle-arrow-right"></span></a>
  1134. <a href="index.html" class="btn btn-neutral" title="Welcome to FlatCAM’s documentation!"><span class="icon icon-circle-arrow-left"></span> Previous</a>
  1135. </div>
  1136. <hr/>
  1137. <div role="contentinfo">
  1138. <p>
  1139. &copy; Copyright 2014, Juan Pablo Caram.
  1140. </p>
  1141. </div>
  1142. <a href="https://github.com/snide/sphinx_rtd_theme">Sphinx theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>
  1143. </footer>
  1144. </div>
  1145. </div>
  1146. </section>
  1147. </div>
  1148. </body>
  1149. </html>