Last week, I wrote a Workbench article about creating a 3D model and printing your own bases on a low-end 3D printer. And Minimaker said:
You can use this to make a library of bases which can can select.
That reminded me that I'd heard something about customizable 3D models. Why build multiple models, if you can make one model that can be customized?
So I decided to look into the possibilities.
Thingiverse & Customizable Models
Thingiverse is one of several 3D model libraries on the internet. It supports the MakerBot line of printers, but 3D models can be used by any printer.
Some models on Thingiverse are customizable. What that means if that if users see a customizable model on that website, they can launch an app through the website that allows them to interact with that model. By changing settings and options, users can change the output of the model and save their results.
That's pretty cool, but it only works for one type of 3D model – models which have been built using OpenSCAD.
OpenSCAD
When you think of creating a 3D model, you probably think of using a graphical interface to construct the model. OpenSCAD is an entirely different approach. Creating models in OpenSCAD is done by writing a script, similar to a programming language.
OpenSCAD is also freely downloadable.
The basic idea is that, using commands, you can create cubes, spheres and cylinders, and add them, subtract them, and modify them to create more complex objects. It is not a technology you would want to use to sculpt anything organic, but it works great for mechanical shapes.
And, if you write the script in a particular way, the Thingiverse app will understand what the parameters are, and allow users to interact with the model. Parameters are simply things like "how big do you want it to be?" and "do you want this option?" – and this type of modeling is sometimes called parametric modeling.
An Example of OpenSCAD
For instance, here we are in the OpenSCAD program:
A simple script has created three objects. The one on the left is created with the command:
translate([-24,0,0]) { union() { cube(15, center=true); sphere(10); } }
Which means: at location -24, 0, 0, combine ("union") a 15 x 15 x 15 cube and a 10mm sphere.
The middle object is created by this script:
intersection() { cube(15, center=true); sphere(10); }
Which means: Take the intersection (that is, the common parts) of a cube and a sphere.
And the object on the right is created by:
translate([24,0,0]) { difference() { cube(15, center=true); sphere(10); } }
Which means: Take the cube, and subtract the sphere.
Writing My First OpenSCAD Script
So I decided to play around a bit with OpenSCAD. I knew I wanted a script that could make rectangular bases. There are many ways to do that in OpenSCAD, and I may not have picked the optimal way! I decided to use cylinders.
Why cylinders? Two reasons. First of all, in OpenSCAD, nothing is really round – everything is made out of sides. And what's a four-sided cylinder? A cube. Second, you can set the top and bottom of a cylinder to be different sizes. That allows you to make cones, pyramids… and beveled edges.
So, by creating two four-sided cylinders, I could create a square or rectangular base with sides that could be straight or sloped, depending on what the user wants.
But what if the user wants a base longer than two boxy cylinders? Well, there's a function called hull which is kind of like throwing a tarp over two objects and creating a single object. So by hulling the two cylinders, no matter how far apart they are, the script will make bases of any width and length.
More Options
Playing with the script further, I realized that by changing the number of faces of the cylinders, I could not only produce rectangular bases, but semi-octagonal and round/lozenge ones, too.
What if a user wanted a slot? Well, a slot is simply a shape subtracted from the original object. I added options for straight or angled slots, or double slots.
I've seen bases with indented tops, too, so I added that option too. It's just subtracting a shape from the top of the base.
And if you want a central hole, maybe for a magnet? That's just a subtracted cylinder. I added options for diamond, hexagonal and 'round' holes.
And maybe you want a nameplate? I added an option for a raised surface along the length of the base.
Is it that easy? Yes and no. I did have to refresh my memory of trigonometry to get certain things in the right positions. I also had to rotate some shapes to get them in the right alignment, and rotations are a pain in OpenSCAD because you essentially rotate the frame of reference, and then everything is off-kilter. (Or maybe I'm too new to this.)
Making It Customizable
An OpenSCAD script will be customizable on your own computer, but if you want to upload it to Thingiverse and have it be customizable, you have to make some small changes. The best practice is to put the variable definitions at the start of the script – things like:
Length = 12;
…and then the app will recognize that Length is something which the user should be able to change. You can also add explanations, limit the type of responses possible, and group the options into categories.
The Bases
Here are some of the bases which I've been able to print, all using the same OpenSCAD model.
Basic Shapes
Square, rectangular, round, lozenge, and semi-octagonal bases, of any width, length or height, with straight or sloped sides.
Slotted Bases
Straight slots, angled slots, double slots, offset slots, and you choose the length and width of the slot.
Bases With Indented Tops
The indent matches the shape of the base, but you control how much to indent and how deep to indent.
Bases with Holes
You can add a central hole of any size, in three shapes. (That weird thing on the left is an octagonal pyramid with a square hole.)
Bases with Nameplates
And here's an octagonal base with a raised nameplate. You can set the width, length, and how far the nameplate is offset from the center.
Plinths
This is not really a feature, it's just that you can make very large and tall bases which can serve as platforms or plinths. Here, I've made a giant statue of a Lizardman…
Caveats
One thing you should know is that there doesn't seem to be any easy way to 'foolproof' an OpenSCAD script. In other words, if you set the parameters to something goofy, you may get nothing – literally, an empty space. Or you might get a model that makes no sense, like a base with a hole that's larger than the width of the base!
In certain circumstances, you might be able to enter parameters which will cause an 'undefined surface'. This can be true of any OpenSCAD script. This is usually caused by doing a subtraction right up to the edge of something else, leaving what you might call a floating edge. Fortunately, most 3Dprinters are smart enough to 'fix' the problem and print your model anyway. But if the model won't print, change the parameters a little bit.
Since this is my first OpenSCAD model, I welcome all comments, corrections, bug reports, tips, and feature requests. There are other customizable base models out there, but as far as I could find, none that do what this one does.
Also, OpenSCAD is not the only way to make customizable models. It's just the first one I've learned.
You can interact with the model here on Thingiverse.