How to design a 3D-printed enclosure for your product

Getting started with OpenSCAD and MakerWare


The workflow for making a 3D object using a MakerBot printer goes something like this:

  1. Design your model using a CAD (Computer-Aided Design) application, e.g. OpenSCAD or TinkerCAD. Export your model as an .STL file.
  2. Open the .STL file in MakerWare to modify your printer settings if necessary, and specify where on the build plate it should start printing.
  3. Click the Make button in MakerWare to either save your design to an SD card (in .X3G format) or print directly to the MakerBot via USB.

In this tutorial we will focus mostly on the first step, using OpenSCAD. OpenSCAD is an open-source CAD design application, where you specify what your design should look like using a script, which is then compiled into a 3D model. OpenSCAD is well supported on Thingiverse, the open repository for CAD designs. MakerBot has developed a Thingiverse tool called the Customizer, which allows other people to easily change the parameters of your script to generate their own custom designs. See for example this knob design, which has an “Open in Customizer” button to change parameters like the knob width, height and number of indentations.

A customised control knob with five indentations

OpenSCAD is available for Windows, Mac and Linux. I’ve had some rendering problems on a MacBook Pro with OS X Lion installed. Apparently this is an issue with the Intel HD3000 drivers, so if your 3D model isn’t rendering correctly on your Mac, consider upgrading to OS X Mavericks.

A free tutorial series that I’ve found invaluable for learning OpenSCAD is over on the MakerBot website. Have a look at the first 5 tutorials before you continue. There is also the OpenSCAD User Manual on Wikibooks if you get stuck.

So how do you go about designing an enclosure for your product? Let’s start off with a basic enclosure for a Raspberry Pi, which you can always modify later. To make sure that everything fits, let’s first load a model of the Raspberry Pi components into OpenSCAD:

use <rpi.scad>

To display the Pi as a see-through component, use the % modifier:

%board();

Creating the base

Let’s start by creating a base for the enclosure. We do this by creating a cube that’s a bit larger than the Pi itself, and create rounded corners for the cube using a Minkowski transformation and a small cylinder:

module base()
{
$fn=50;
minkowski() {
cube([base_x,base_y,base_z]);
cylinder(r=2,h=1);
}
}

The $fn variable is used to specify the number of fragments used to build up the shape.

The Raspberry Pi components (see-through) and the base with rounded corners (yellow).

Building up the sides

To build up the sides, we just need to increase the base_z variable and then subtract a volume in the middle to create a space inside the cube:

module base_block() {
difference() {
base();
translate([base_width,base_width,base_width])
cube([base_x-base_width,base_y-base_width,base_z]);
}
}
Building up the sides and subtracting a volume in the middle

But how do we make holes in the sides for the components? We can do this by taking the difference of our base block and the Pi components:

module bottom() {
difference () {
base_block();
translate([5,5,6])
board();
}
}

Creating some slits

In order to reduce the amount of material that we use to print the object, and to increase the ventilation in the enclosure, we want to create a number of slits in the base. This can be achieved by using a simple for() loop and subtracting that from our base object:

module slits() {
for (i = [0:16]){
translate([i*5+base_x*0.08,base_y*0.08,-0.25])
cube([2, base_x*0.6, base_width+4]);
}
}
difference() {
bottom();
slits();
}
The final part, with slits in the bottom

Sending it off to the printer

Export your design from OpenSCAD as an STL file using “Design->Export as STL”. Below are some instructions for using a MakerBot Replicator and MakerWare to print your object.

When you open MakerWare, click the “Add” button to load your .STL file. You can see where on the build plate your object will be built, and you can move, scale and turn the object using the controls on the left. When you’re ready to send it off to the printer, click “Make”, make sure the right material (PLA/ABS) is selected and adjust the settings as necessary. Under the “Advanced Options”, there is a checkbox for “Use Preview before printing”. This is very useful if you’d like an estimate of how much material will be used to print your object, as well as an estimated time to print.

If your printer is connected via USB you can send it off to the printer directly. Alternatively, click “Export” and save the resulting .X3G file on an SD card, which you can then pop in the printer and print using the controls on the printer itself.

The MakerWare software with the design loaded
The finished print on the build plate
The current design is still a work-in-progress, as the enclosure is still a bit too large for the Raspberry Pi.

All the design files for this tutorial can be downloaded from Thingiverse.


Feedback and comments are welcomed, and let me know if you make any improvements to the design.

If you have found this tutorial helpful, please bash that Recommend button below.