{"id":16499,"date":"2020-10-12T21:07:12","date_gmt":"2020-10-13T01:07:12","guid":{"rendered":"https:\/\/scruss.com\/blog\/?p=16499"},"modified":"2024-12-04T07:14:00","modified_gmt":"2024-12-04T12:14:00","slug":"memo-to-self-trivial-hp-gl-%e2%86%92-gcode-converter","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2020\/10\/12\/memo-to-self-trivial-hp-gl-%e2%86%92-gcode-converter\/","title":{"rendered":"memo to self: trivial HP-GL \u2192 GCode converter"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"904\" height=\"904\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/10\/phweeen.png\" alt=\"an outlined lozenge with the work &quot;Phween!&quot; in italcis in teh centre. The text is hatched diagonally.\" class=\"wp-image-16501\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/10\/phweeen.png 904w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/10\/phweeen-320x320.png 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/10\/phweeen-160x160.png 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/10\/phweeen-768x768.png 768w\" sizes=\"auto, (max-width: 904px) 100vw, 904px\" \/><figcaption>what the sample files render<\/figcaption><\/figure>\n\n\n\n<p><strong>Updated<\/strong>: here&#8217;s a better one. Who knew that hp2xx had a gcode mode built in?<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nhp2xx -t -m nc -z 0 -Z 5 -f - file.hpgl | grep -v &#039;^M0.&#039; | sed &#039;s\/^G01\/G0\/;&#039; | awk &#039;BEGIN {print &quot;G21\\nG90&quot;;} END {print &quot;G0 Z5&quot;;} {print;}&#039; &gt; file.gcode\n<\/pre><\/div>\n\n\n<p>Aah, no: forget the stuff below.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nhp2xx -t -m hpgl -f - phweeen.hpgl | sed &#039;s\/;\/\\n\/g;&#039; | grep -v &#039;^SP&#039; | grep -v PA | awk -F, &#039;BEGIN {print &quot;G0X0Y0Z5&quot;;} \/^PU\/ {sub(\/PU\/, &quot;&quot;, $1); printf(&quot;G0Z5\\nG0X%fY%f\\n&quot;, $1\/40.0, $2\/40.0);} \/^PD\/ {sub(\/PD\/, &quot;&quot;, $1); printf(&quot;G0Z0\\nG0X%fY%fZ0\\n&quot;, $1\/40.0, $2\/40.0);} END {print &quot;G0Z5&quot;;}&#039; &gt; ~\/Desktop\/phweeen.gcode\n<\/pre><\/div>\n\n\n<ol class=\"wp-block-list\"><li>likely targets a <a href=\"https:\/\/github.com\/bdring\/midTbot_esp32\">MidTBot<\/a> a little too much<\/li><li>ignores pen changes<\/li><li>assumes pen up means tool Z=5 and pen down means tool Z=0<\/li><li>only understands <strong>PU<\/strong> (move) and <strong>PD<\/strong> (draw) commands<\/li><li>requires hp2xx<\/li><li>tested with trivially few sample files exported as HP-GL from Inkscape<\/li><li>doesn&#8217;t care about paper size; your plotter does, though.<\/li><\/ol>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/10\/hpgl_gcode_samples.zip\">hpgl_gcode_samples<\/a><a href=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2020\/10\/hpgl_gcode_samples.zip\" class=\"wp-block-file__button\" download>Download<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Updated: here&#8217;s a better one. Who knew that hp2xx had a gcode mode built in? Aah, no: forget the stuff below. likely targets a MidTBot a little too much ignores pen changes assumes pen up means tool Z=5 and pen down means tool Z=0 only understands PU (move) and PD (draw) commands requires hp2xx tested [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2],"tags":[],"class_list":["post-16499","post","type-post","status-publish","format-standard","hentry","category-goatee-stroking-musing-or-something"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-4i7","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=16499"}],"version-history":[{"count":4,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16499\/revisions"}],"predecessor-version":[{"id":17678,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16499\/revisions\/17678"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=16499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=16499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=16499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}