OpenSCAD Intermediates: How to Make Organic Shapes

In this OpenSCAD tutorial series we’ve covered the basics of the OpenSCAD interface, how to make 2D forms, how to make some basic 3D forms, how to position those forms in 3D space, the different ways to combine forms, how to create mashups of one or more existing STL’s and OpenSCAD forms, how to use modules to reuse your code to make your life easier, how to extrude flat 2D forms into 3D forms, and how to fix design problems.  Although I described a few of the last tutorials as “intermediate” levels, that’s really only because you learned the basics so quickly from the first few tutorials.

Today I’d like to show you how easy it is to make some neat organic looking forms with OpenSCAD.  The secret behind doing so are two functions, “hull” and “minkowski.”  Let’s learn a little bit about what each of these functions do and try out some code.  More, after the break!

  • Hull
    • The “hull” function essentially connects two or more 2D shapes, almost as if they were “shrink-wrapped” together.  Suppose you wanted to create an pear-shape, you could do this by creating two circles – one larger than another – and tracing around the both of them.  Let’s see what these two circles would look like without the hull function first:
      1. translate([0,50,0]) circle(30);
      2. circle(50);
    • What you should expect to see is the two circles, somewhat overlapping.  Now, let’s see how the hull function automatically connects these two shapes into just one shape:
      1. “hull()
      2. {
      3. translate([0,40,0]) circle(30);
      4. circle(50);
      5. }”
    • By using hull to connect squares and circles, anyone can easily create extremely organic seeming shapes.  One interesting way to use this function is to create just the major points of your desired complex organic 2D object, and then apply the hull function as we did above.  This way you can be sure the final object created by hull would have all the important features you were trying to create.
    • Pro Tip:  The hull function can be used with more than one 2D shape.
    • Pro Tip:  Since a complex object created with hull is also a 2D shape, you can make another 2D shape by using hull around other 2D shapes and other complex shapes created by a hull function.
  • Minkowski
    • The “minkowski” function basically takes one 2D shape and traces it around the edge of another 2D shape.  As with “hull”, the best way to understand how this function works is to see how the two objects appear without, and then with, the minkowski function around them.  So, first try:
      1. square(50);
      2. circle(10);
    • You should see a square and a circle overlapping at the origin point.  Now, let’s try it again with the minkowski function around those two 2D objects:
      1. minkowski()
      2. {
      3. square(50);
      4. circle(10);
      5. }
    • You should now see a square with rounded corners!
  • Wait, wait…  I promised you organic, right?  Try this on for size:
    • minkowski()
    •      {
    •      circle(4);
    •      for(i=[0:5])
    •           {
    •           rotate([0,0,360/5 * i])
    •           hull()
    •                {
    •                translate([20,0,0]) square(10);
    •                square(2);
    •                }
    •           }
    •      }
  • Conclusion
    • Hull and Minkowski functions let you combine two or more 2D shapes in ways that would be really difficult in other methods.  Using these two interesting functions in conjunction make even more amazing organic appearing shapes possible.  Once you’ve created a complex shape by using hull, or several hull objects combined, being able to trace another shape around that complex object can make interesting, and sometimes slightly unpredictable results.
  • Homework Assignment
    • Now that you’ve learned how to use hull and minkowski functions, show everyone what you can do!  Use what you’ve learned today to either (a) create one 2D object using hull and one 2D object using minkowski or (b) one object that uses both hull and minkowski, then upload your your OpenSCAD file and the STL to Thingiverse.
    • Extra credit:  If you want to make me extra proud, please tag it with “openscadtutorial.”  That way anyone who clicks that link will be able to see all of our hard work!
  • Last but not least, today’s gold star goes to… rvanchie for their OpenSCAD tutorial homework.  I’d like to include a picture of your homework next time – so don’t forget your homework!

The topic of the next tutorial is up to you.  What would you like to learn next?  Is there something you’d like to learn how to make?  Is there something more you’d like to learn about some of the topics we’ve covered?

Error - could not find Thing 20790.