Printed It: Custom Enclosure Generator

You’ve written your firmware code, etched your own PCB, and now it’s time to put that awesome new project of yours into an enclosure. Unfortunately, all you have is a generic Radio Shack project box that you picked up when they were clearing out their inventory. If you put your project in that, it’ll have all the style and grace of a kid wearing hand-me-down clothes. Your project deserves a tailor-made enclosure, but the prices and lead time on custom plastic enclosures are prohibitive for one-off projects.

In Ye Olde Olden Days, the next step might have been to start bending some sheet metal. But it’s the 21st century, and we’ve got mechanization on our side. The “Ultimate Box Maker” by [Heartman] is a fully parametric OpenSCAD design which allows you to generate professional looking enclosures by simply providing your desired dimensions and selecting from a few optional features. In a couple of hours, you’ll have a custom one-of-a-kind enclosure for your project for a few cents worth of filament.

That’s the idea, at least. For this edition of “Printed It”, I’ll be taking a look at the “Ultimate Box Maker” by generating and printing a basic enclosure. As somebody whose Radio Shack was out of enclosures by the time I got there and who doesn’t want to slice his hand open folding sheet metal, I’m very interested in seeing how well this design works.


So in theory, this design is supposed to work with the Thingiverse Customizer, which is basically just a web front-end for OpenSCAD. You get nice little sliders and dialog boxes, and once you have all your information entered, it will render you a custom STL to download. It’s arguably one of the best ideas MakerBot has come up with in regards to how Thingiverse works. Unfortunately, at the time of this writing, Customizer doesn’t seem to work anymore and just gives an error about missing Sigh.

In that case, we’ll need to download the .scad file from the “Thing Files” tab and open it up in OpenSCAD locally. All the configuration values are up at the top of the file and clearly labeled, which makes this fairly easy.

Obviously, you’re going to want to adjust the overall box dimension variables at the minimum. But there are also a whole set of options for PCB standoffs (position, diameter, screw size, etc), as well as options related to the built-in vents.

Making use of the OpenSCAD import(); function, you can bring in an STL of an existing PCB and see exactly how it will look in the rendered case. As a demonstration, I’ll be making a small enclosure for the Pi Zero, so I’ve imported an STL of it and used that to align the PCB standoffs. But even if you don’t import an STL to use as a guide, there’s a helpful “ghost PCB” that floats around inside the case while your editing the file in OpenSCAD.

Exporting the STL

Once you’ve edited the variables to your liking, you’ll want to scroll a little farther down in the code to find a section that looks like the following:

/* [STL element to export] */
//Coque haut - Top shell
TShell = 0;// [0:No, 1:Yes]
//Coque bas- Bottom shell
BShell = 1;// [0:No, 1:Yes]
//Panneau avant - Front panel
FPanL = 0;// [0:No, 1:Yes]
//Panneau arrière - Back panel
BPanL = 0;// [0:No, 1:Yes]

These options selectively turn on and off the different parts of the model for when it comes time to export the STL. If you don’t turn the other parts off before export, you’ll just get a useless “assembled” STL.

Unfortunately, the script is not smart enough to reposition the objects for STL export; so you’ll have to manually flip over the top piece in your slicer, for example. Another annoyance I found is that, even if you turn off the bottom of the case (BShell), the PCB feet still remain. You need to go back up to the script configuration settings and turn them off manually, look for the option called “PCBFeet”.

Having worked with OpenSCAD for a while I know why [Heartman] wouldn’t have included rotating the parts on export: it’s a whole lot of code to implement something that the end user can do with a click in their slicer. But making sure the PCB standoffs aren’t rendering when the user is just trying to get the top or side panel is a fairly big omission and would really only take a single conditional statement to fix.

Finally, there is some early support for generating customized front and rear panels, including functions to generate openings and labels. But personally, I would suggest just taking the blank panel generated by the OpenSCAD script and importing it into a 3D CAD program your comfortable with. The panel generation code just isn’t ready for prime-time, in my opinion.


The design that [Heartman] has come up with for the case is really quite clever, and shouldn’t pose a problem printing. There are no overhangs so support is unnecessary, though you may want to turn off the vents if your printer has issues with stringing, as the thin openings can get clogged up. I printed my case at 0.2 mm layers and 15% infill, though larger cases could probably get away with 0.3 mm layer height for the sake of speed.

The design is forgiving in terms of tolerances, and no cleanup was needed after printing to get the parts together. The fit on the front and rear panels is perfect; loose enough that they don’t need to be sanded to git in the channels but tight enough that they don’t rattle around once the lid is screwed down. Incidentally, you must screw the lid down, as the two pieces don’t actually have any interlocking components. A potential improvement to the design would be a way to make the lid snap-fit.

Final Thoughts

Overall, I think the enclosures generated by the “Ultimate Box Maker” OpenSCAD script are fantastic. They look extremely professional, are very sturdy, and print easily. This is definitely a design I’ll be adding to my regular bag of tricks going forward.

I especially like that this is a printable design that clearly addresses a valid need. One-off projects need one-off enclosures, and 3D printing is perfect for that. While we’ve previously covered printed tools that deserve a spot on your bench, the argument could always be made that you’d be better off buying the “real thing”. But I believe this project offers a solution which is actually superior to traditional methods in a number of ways.

Thingiverse’s Customizer dropping the ball on this one is especially annoying, as [Heartman] went through the trouble of making sure his design worked with it — there’s some special syntax Thingiverse has you add to OpenSCAD to make their front-end work. Having a web-based tool to generate custom enclosures would be extremely handy, and I wonder if somebody in the community might just take up the challenge of restoring the service MakerBot seems not to maintain?

27 thoughts on “Printed It: Custom Enclosure Generator

  1. hi everyone, i want you to know i’m one of the snobs in this here comment section and i have to say:

    openscad is easy. it’s easier to just make your own enclosure from scratch, especially if it’s as simple as this one.

    1. You’re seriously going to try and say it would be easier/faster to write the code for a new enclosure than simply use this proven code somebody has gone through the trouble of putting out as open source? Come on…

      1. Well, if you’ve ever needed to make almost exactly the same part many times, you would understand. Boxes are a perfect example, where you might want everything to be the same – wall thickness, edge radius, ventilation slot patterns – but in a different size. There are CAD programs that make this relatively easy, and I guess you could also write Python or C programs to generate STL files, but OpenSCAD includes all the nice 3D things like intersections and unions. Using OpenSCAD is a little like getting fed up with manually renaming a gazillion files using a GUI file explorer, and instead writing a program to do it for you. Doesn’t pay off if you only have a need for two or three custom boxes, but pays off over time.

      2. In my youth I dabbled with POV-Ray.
        OpenScad uses the same principles, so to me it’s easy to think in only few elements and think about the interections and differences.

  2. It’s not a bad place to start and definitely a great effort. I’ve used it a couple of times and have had issues with the tabs that extend to hold the case together printing well (and holding everything tight), so I modded it to use heatset inserts and screws instead of the side tabs. It’s also a great learning tool if you’re just getting started with OpenSCAD (like I am).

  3. It’s nice if you want to throw something quick together. I’d prefer my own design though, often with the minimum possible size in mind. I now also have a cnc router which is great for larger boxes. It’s often quicker to mill something out that’s large than to 3D print it. And the option of mixed materials like wood, acrylic and aluminium is also great.

    1. I use a parametric solidworks model for milling boxes out on my cnc machine. I almost feel like i should turn around and make one from openSCAD for other people. I think the largest challenge is the work holding and that a single setup on a CNC machine is hard to design, Its not impossible but it creates limitations.

  4. I’m not convinced snaping togetherness would be an improvement, it tends to lead to gouging the case to open it and/or not bothering with the screws later on.

  5. Nice looking case. I like the two colors as well. In the past I would modify an existing case as opposed to a Hammond enclosure to get a “professional” look, but 3d printing is getting close (I’m talking hobbyist printers).

      1. Thingiverse’s customizer hasn’t worked for me for months. However, OpenSCAD does have a version that is capable of customization locally. The most updated build has this disabled as of a few weeks ago, but if you download and install the development snapshot, and enable customizer it will enable you to customize the customizer-enabled files downloaded from thingiverse locally.

    1. Too bad clicking open in customizer does not work. They say it may work if you download and install ope scad and some other piece to it, but they also said the customizer would work. It would be nice if HAD checked this stuff out first.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s