{"id":126,"date":"2018-03-19T18:05:51","date_gmt":"2018-03-19T18:05:51","guid":{"rendered":"http:\/\/www.vandelle.com\/blog\/3dprinting\/?p=126"},"modified":"2018-03-19T18:05:51","modified_gmt":"2018-03-19T18:05:51","slug":"modelize-your-first-3d-shape-with-openscad-5","status":"publish","type":"post","link":"https:\/\/www.vandelle.com\/blog\/3dprinting\/2018\/03\/19\/modelize-your-first-3d-shape-with-openscad-5\/","title":{"rendered":"Modelize your first 3D shape with openSCAD #5"},"content":{"rendered":"<h2>5. Modules<\/h2>\n<p>Modules are used to define an object. It\u2019s a very useful feature you must use in every of your projects. The principal advantage is to avoid code duplication and to have a more ridable code.<\/p>\n<p>Syntax:<\/p>\n<pre>module Name(parameters) {\n\n\u00a0\u00a0\u00a0\u00a0 \u201cyour code\u201d\n\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>And to call the module: <strong>Name(parameters);<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Example:<\/p>\n<pre>module Ecroue(h,r){\n\n\u00a0\u00a0\u00a0 difference(){\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cylinder(h,r+0.8,r+0.8);\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 translate([0,0,-1]) cylinder(hauteur+2,r*0.7,r*0.7);\n\n\u00a0\u00a0\u00a0 }\n\n}\n\nEcroue(3,4);<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>6. Other Functionnalities<\/h2>\n<p>Now you know all the basic functionalities there is a multiple of over one that can be very useful I can\u2019t list them all but there is some that can interest you if you want to go further in openSCAD.<\/p>\n<p>&nbsp;<\/p>\n<h3>a. Text<\/h3>\n<p>To include text, you have 3 variables:<\/p>\n<ul>\n<li>text(\u201cmyText\u201d,\u201dmyStyle\u201d) include your text<\/li>\n<li>resize([x,y]) change the size of the text<\/li>\n<li>offset(number) the width of the text<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>syntax:<\/p>\n<pre>resize([30,10]) offset(0.5) text(\"Tutorial\",\"Arial:style=Bold\");\n<\/pre>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-178\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/1-2-300x174.png\" alt=\"\" width=\"473\" height=\"274\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>b. Minkowski<\/h3>\n<p>Minkowski is a cool functionality that will allowed you to do shapes that are very hard to do with difference(). It will do very elegant shapes like this one:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-179\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/2-2-300x203.png\" alt=\"\" width=\"410\" height=\"277\" \/><\/p>\n<p>&nbsp;<\/p>\n<pre>$fn=100;\n\nminkowski() {\n\n\u00a0\u00a0 hull() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cube([20,20,1],center=true);\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 translate([0,0,20]) cylinder(1,8,8);\n\n\u00a0\u00a0\u00a0 }\n\n\u00a0\u00a0 sphere(r=5);\n\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>7. Final Exercises<\/h2>\n<p>&nbsp;<\/p>\n<p>1) Try to reproduce the previous shape (<a href=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/modelize-your-first-3d-shape-with-openscad-3\/\" target=\"_blank\" rel=\"noopener\">Exercise 3<\/a>) with modules. (<a href=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/modelize-your-first-3d-shape-with-openscad-correction\/\" target=\"_blank\" rel=\"noopener\">correction<\/a>)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-180\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/4-3-300x236.png\" alt=\"\" width=\"400\" height=\"315\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>2)Do a key ring with a module for the key and on for the ring. In this key ring put text encrusted with a hull shape. (<a href=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/modelize-your-first-3d-shape-with-openscad-correction\/\" target=\"_blank\" rel=\"noopener\">correction<\/a>)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-181\" src=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/wp-content\/uploads\/sites\/6\/2018\/03\/5-3-300x241.png\" alt=\"\" width=\"392\" height=\"315\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>8. Conclusion<\/h2>\n<p>I hope you liked my tutorial and that it will help you for you 3d printing project. If you want some idea for your first shapes to print go check my creation in <a href=\"http:\/\/www.vandelle.com\/blog\/3dprinting\/3d-model\/\" target=\"_blank\" rel=\"noopener\">3D models<\/a> or on<a href=\"https:\/\/www.thingiverse.com\/\" target=\"_blank\" rel=\"noopener\"> thinginverse<\/a> who is a very cool website with a large database of 3D object created by the community.<\/p>\n<p>I will just finish with a topic on features I would personally like to be implemented on my favorite 3D creation software. For my part it will be very simple things like scroll past end, parenthesis and brackets handle to go faster when tiping.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>5. Modules Modules are used to define an object. It\u2019s a very useful feature you must use in every of your projects. The principal advantage is to avoid code duplication and to have a more ridable code. Syntax: module Name(parameters) { \u00a0\u00a0\u00a0\u00a0 \u201cyour code\u201d } &nbsp; And to call the module: Name(parameters); &nbsp; Example: module [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":88,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-126","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/posts\/126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/comments?post=126"}],"version-history":[{"count":0,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/posts\/126\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/media?parent=126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/categories?post=126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vandelle.com\/blog\/3dprinting\/wp-json\/wp\/v2\/tags?post=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}