{"id":3727,"date":"2012-09-13T02:23:48","date_gmt":"2012-09-13T09:23:48","guid":{"rendered":"http:\/\/www.iearobotics.com\/blog\/?p=3727"},"modified":"2013-01-30T11:31:31","modified_gmt":"2013-01-30T18:31:31","slug":"enhancing-openscad-ii-bevel-library","status":"publish","type":"post","link":"http:\/\/www.iearobotics.com\/blog\/2012\/09\/13\/enhancing-openscad-ii-bevel-library\/","title":{"rendered":"Enhancing openscad (II): Bevel library"},"content":{"rendered":"<p><a href=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/bevel-ej1-box.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/bevel-ej1-box.png\" alt=\"\" title=\"bevel-ej1-box\" width=\"500\" height=\"447\" class=\"aligncenter size-full wp-image-3729\" srcset=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/bevel-ej1-box.png 500w, http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/bevel-ej1-box-300x268.png 300w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><\/p>\n<p>(First part: <a href=\"http:\/\/www.iearobotics.com\/blog\/2012\/09\/10\/enhancing-openscad-with-the-attach-library\/\">Enhancing openscad with the attach library<\/a>)<\/p>\n<h2>Introduction<\/h1>\n<p>There is one very common operation that has to be done in nearly all the designs: <strong>beveling edges<\/strong>. It can be done on the <strong>convex side<\/strong>, for avoiding sharp edges, or on the <strong>concave side<\/strong>, for reinforce the part (avoiding the 90 degrees connection between parts).<\/p>\n<p>With the <a href=\"http:\/\/www.thingiverse.com\/thing:30336\">bevel library<\/a> I am developing doing these two operations is a piece of cake. Let&#8217;s see some examples<\/p>\n<h2>Beveling the exterior edges<\/h2>\n<p><a href=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-1.png\" alt=\"\" title=\"ej1-1\" width=\"500\" height=\"227\" class=\"aligncenter size-full wp-image-3736\" srcset=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-1.png 500w, http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-1-300x136.png 300w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><\/p>\n<p>Let&#8217;s take a cube as an example. We want to bevel the top-right edge. We will use the concept of <strong>connector<\/strong> (the same that is used for the <a href=\"http:\/\/www.iearobotics.com\/blog\/2012\/09\/10\/enhancing-openscad-with-the-attach-library\/\">attach operator<\/a>). First we draw the cube and define two connectors in the same position (the same attachment point). The first one is on the edge we want to bevel. The other is normal and should point to the exterior bisector. <\/p>\n<p>  Using the <strong>connector()<\/strong> module they can be easily viewed for debugging. It is also useful to make the cube transparent for seeing the connectors better:<\/p>\n<p><code><br \/>\nsize=[40,40,15];<\/p>\n<p>\/\/-- Define the Connectors<br \/>\n\/\/--     position,               orientation, 0<br \/>\nec1 = [ [size[0]\/2, 0, size[2]\/2], [0,1,0], 0];<br \/>\nen1 = [ ec1[0],                    [1,0,1], 0];<\/p>\n<p>\/\/-- Debug! Show the connectors<br \/>\nconnector(ec1);<br \/>\nconnector(en1);<\/p>\n<p>\/\/-- Draw the cube (transparent for debugging)<br \/>\ncolor(\"Yellow\",0.4)<br \/>\n  cube(size,center=true);<br \/>\n<\/code><\/p>\n<p>Now is when the magic comes:<\/p>\n<p><a href=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-21.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-21.png\" alt=\"\" title=\"ej1-2\" width=\"400\" height=\"358\" class=\"aligncenter size-full wp-image-3747\" srcset=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-21.png 400w, http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-21-300x268.png 300w\" sizes=\"auto, (max-width: 400px) 85vw, 400px\" \/><\/a><\/p>\n<p>Invoke the <strong>bevel()<\/strong> module, passing the connectors as parameters, as well as the corner radius, the bevel resolution and the length (l). Automatically a beveled concave corner part is placed on the connectors, with the right orientation. In this example the color has been change to transparent blue to see the new part better.<\/p>\n<p><code><br \/>\ncolor(\"Blue\",0.4)<br \/>\n  bevel(ec1, en1, cr = 8, cres=10, l=size[1]+2);<br \/>\n<\/code><\/p>\n<p>The edge has not been beveled yet&#8230; we still have to apply the <strong>difference()<\/strong> operator:<\/p>\n<p><code><br \/>\ndifference() {<br \/>\n  cube(size,center=true);<br \/>\n  bevel(ec1, en1, cr = 8, cres=10, l=size[1]+2);<br \/>\n}<br \/>\n<\/code><\/p>\n<p>and there it is!<\/p>\n<p><a href=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-3.png\" alt=\"\" title=\"ej1-3\" width=\"400\" height=\"258\" class=\"aligncenter size-full wp-image-3754\" srcset=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-3.png 400w, http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej1-3-300x193.png 300w\" sizes=\"auto, (max-width: 400px) 85vw, 400px\" \/><\/a><\/p>\n<p>Change the corner resolution, or the radius for modifying the beveling. Also you can easily <strong>add more bevel() operations<\/strong> into the difference() so that you bevel more egdes. Here is another part with different kind of beveled edges:<\/p>\n<p><a href=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/bevel_02_cube.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/bevel_02_cube.png\" alt=\"\" title=\"bevel_02_cube\" width=\"400\" height=\"264\" class=\"aligncenter size-full wp-image-3755\" srcset=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/bevel_02_cube.png 400w, http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/bevel_02_cube-300x198.png 300w\" sizes=\"auto, (max-width: 400px) 85vw, 400px\" \/><\/a><\/p>\n<h2>Reinforcing parts: buttress<\/h2>\n<p>Adding buttress to the union of orthogonal parts is done in a similar way than the edge beveling. First the 2 connectors should be defined, with a vector on the edge direction and another normal to it, pointing to the interior bisector.<\/p>\n<p><a href=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-3.png\" alt=\"\" title=\"ej3-3\" width=\"500\" height=\"165\" class=\"aligncenter size-full wp-image-3759\" srcset=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-3.png 500w, http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-3-300x99.png 300w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><\/p>\n<p><code><br \/>\n\/\/-- part parameters<br \/>\nsize=[30,30,30];<br \/>\nth = 3;<\/p>\n<p>\/\/-- Define the connectors<br \/>\nec1 = [ [0,-size[1]\/2+th,-size[2]\/2+th], [1,0,0],  0];<br \/>\nen1 = [ ec1[0],                          [0,1,1], 0];<\/p>\n<p>\/\/-- Show the connectors (Debug)<br \/>\nconnector(ec1);<br \/>\nconnector(en1);<\/p>\n<p>\/\/-- Part we want to reinforce<br \/>\ncolor(\"Yelow\",0.5)<br \/>\ndifference() {<br \/>\ncube(size,center=true);<br \/>\ntranslate([0,th,th])<br \/>\ncube([size[0]+2,size[1],size[2]],center=true);<br \/>\n}<br \/>\n<\/code><\/p>\n<p>Now one buttress is added:<\/p>\n<p><code><br \/>\nbconcave_corner_attach(ec1,en1,l=th,cr=8,cres=0);<br \/>\n<\/code><\/p>\n<p><a href=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-4.png\" alt=\"\" title=\"ej3-4\" width=\"400\" height=\"258\" class=\"aligncenter size-full wp-image-3764\" srcset=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-4.png 400w, http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-4-300x193.png 300w\" sizes=\"auto, (max-width: 400px) 85vw, 400px\" \/><\/a><\/p>\n<p>Easy, does not it? \ud83d\ude42  Again, playing with the parameters, or adding more connectors, different reinforments are created:<\/p>\n<p><a href=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-5.png\" alt=\"\" title=\"ej3-5\" width=\"500\" height=\"259\" class=\"aligncenter size-full wp-image-3767\" srcset=\"http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-5.png 500w, http:\/\/www.iearobotics.com\/blog\/wp-content\/uploads\/2012\/09\/ej3-5-300x155.png 300w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><\/p>\n<p>Happy Beveling and reinforcing!!!<\/p>\n<p><a href=\"http:\/\/www.iearobotics.com\/wiki\/index.php?title=Juan_Gonzalez:Main\">Obijuan<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>(First part: Enhancing openscad with the attach library) Introduction There is one very common operation that has to be done in nearly all the designs: beveling edges. It can be done on the convex side, for avoiding sharp edges, or on the concave side, for reinforce the part (avoiding the 90 degrees connection between parts). &hellip; <a href=\"http:\/\/www.iearobotics.com\/blog\/2012\/09\/13\/enhancing-openscad-ii-bevel-library\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Enhancing openscad (II): Bevel library&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,10],"tags":[],"class_list":["post-3727","post","type-post","status-publish","format-standard","hentry","category-plastic-valley","category-reprap"],"_links":{"self":[{"href":"http:\/\/www.iearobotics.com\/blog\/wp-json\/wp\/v2\/posts\/3727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.iearobotics.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.iearobotics.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.iearobotics.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.iearobotics.com\/blog\/wp-json\/wp\/v2\/comments?post=3727"}],"version-history":[{"count":43,"href":"http:\/\/www.iearobotics.com\/blog\/wp-json\/wp\/v2\/posts\/3727\/revisions"}],"predecessor-version":[{"id":3816,"href":"http:\/\/www.iearobotics.com\/blog\/wp-json\/wp\/v2\/posts\/3727\/revisions\/3816"}],"wp:attachment":[{"href":"http:\/\/www.iearobotics.com\/blog\/wp-json\/wp\/v2\/media?parent=3727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.iearobotics.com\/blog\/wp-json\/wp\/v2\/categories?post=3727"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.iearobotics.com\/blog\/wp-json\/wp\/v2\/tags?post=3727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}