OpenSCAD Intermediates: How to Make Complex Organic Shapes

Cyborg Beast OpenSCAD prototype

Cyborg Beast OpenSCAD prototype

OpenSCAD tutorials for the MakerBot blog.  In that OpenSCAD tutorial series I 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.  One of the last tutorials was on how to make organic looking shapes using OpenSCAD.1  However, I have a few design tricks left to share.  A little over 18 months ago I left off the series suggesting as new topics.2 There’s one particular “trick” I am using a lot as I work on designing a printable parametric prosthetic. This trick is somewhat easier to explain using pictures.  Suppose you wanted to make a shape that looked something like a “jack,” but you wanted it to have curved surfaces at the center.  Let’s see what happens when we try to use the “hull()” command.  Do do this, we’ll make a sphere at the center and put eight more spheres around it.  The code for this example is basically irrelevant, but I’ll provide it anyhow.

sphere(r=10);
rotate([0,0,0]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,0,90]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,0,180]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,0,270]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,180,0]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,180,90]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,180,180]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,180,270]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);

There’s a much easier way to create the 8 “orbiting” spheres, but that’s another post unto itself.  :)  Here’s what the above code will create:

Nine little spheres (I named one of them Pluto!)

Nine little spheres (I named one of them Pluto!)

Now, let’s use the “hull()” command to wrap around these spheres.

hull()
{
sphere(r=10);
rotate([0,0,0]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,0,90]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,0,180]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,0,270]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,180,0]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,180,90]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,180,180]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
rotate([0,180,270]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10);
)

That code will make this:

Nine spheres to... a box?

Nine spheres to… a box?

The result looks nothing like a jack! It looks more like a box with rounded edges. The limitation with the “hull()” command3 is that it connects all the outside points from the various shapes.  The result is more like what the objects would look like if you covered them in plastic wrap – but not what they would look like if you tried to use shrink wrap.4 However, our goal is to get a jack.  How should we go about this?  The same way we eat an elephant.56 We need to use “hull()” multiple times7 to connect the central sphere to the eight surrounding spheres.

hull() { sphere(r=10);
rotate([0,0,0]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10); }
hull() { sphere(r=10);
rotate([0,0,90]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10); }
hull() { sphere(r=10);
rotate([0,0,180]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10); }
hull() { sphere(r=10);
rotate([0,0,270]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10); }
hull() { sphere(r=10);
rotate([0,180,0]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10); }
hull() { sphere(r=10);
rotate([0,180,90]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10); }
hull() { sphere(r=10);
rotate([0,180,180]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10); }
hull() { sphere(r=10);
rotate([0,180,270]) translate([100,100,100*pow(2,0.5)/1.5]) sphere(r=10); }

The result would look like:

Much better!

Much better!

By breaking the overall design into pieces, you can use the “hull()” command to connect pieces of the design to one another in a seemingly organic fashion.  Here’s a set of pictures of my most recent work that uses these design tricks.

This slideshow requires JavaScript.

  1. Full list here:

    1. OpenSCAD Basics: The Setup
    2. OpenSCAD Basics: 2D Forms
    3. OpenSCAD Basics: 3D Forms
    4. OpenSCAD Basics: Manipulating Forms
    5. OpenSCAD Intermediates: Combining Forms
    6. OpenSCAD Intermediates: Mashups
    7. OpenSCAD Intermediates: Modularity
    8. OpenSCAD Intermediates: Extruding 2D Objects
    9. OpenSCAD Intermediates: Fixing Design Problems
    10. OpenSCAD Intermediates: How to Make Organic Shapes
    11. OpenSCAD Design Tips
    12. OpenSCAD Design Tips: How to Make a Customizable Thing

    []

  2. These are, in no particular order:

    • How to sketch an object with OpenSCAD
    • How to easily make regular solids – other than cubes and cylinders, like hexagons, pentagons, octagons, etc
    • How to easily make symmetrical solids
    • How to easily make irregular, but symmetrical solids

    []

  3. I almost typed “problem,” but in this case it probably is just a feature []
  4. That’s the best analogy I can come up with []
  5. One bite at a time. []
  6. It’s such a damn shame when a cool domain name is taken – and there’s nothing there.  Such as eatanelephant.com []
  7. 8 times []
March 30, 2014 | Comments Closed

Comments are closed.