Parametric Box Script Generator

A few years back I was prototyping a data collecting product with an arduino at it’s core. The arduino would have a SD card shield to collect the data on,  a motor driving shield, and poll data from various types of sensors. I developed the prototype in my garage and I was looking to transition the prototype to the field. I wanted to transform my prototype from a bundle of wires on a rack to an enclosed device with well defined plugins, ports, etc, so non-technical people could just plug it in. I tried using a simple enclosure from a well known retailer, and it would hold everything with space to spare, but customizing ports was a bit of a pain. My first goal as a member of my local hacker space, Sector 67, was to use the laser cutter and design a parametric box that would be quick to make, and easy to take apart and redesign.

Examples of parametric boxes
Examples of parametric boxes

So what does parametric mean? Basically parametric refers to the ability to alter the structure of an object (usually a computer model) by simply changing one or a few parameters, and the model is structured in such a way that sub-elements have built in logic to adjust themselves accordingly. For example, programs from companies like Solidworks, Autodesk, and others have the ability to build parametric designs. The software I used for this box is an open source program called OpenSCAD, OpenSCAD.org.

OpenSCAD models 3D and 2D objects via a scripting language. The software allows you start off with basic primitives (2D: circle, square, polygons ; 3D: cube, cylinder, sphere) then add, subtract, union, etc until you get the object with the geometry you need. The language has features to define variables, for loops, modules and allows you to pass variables that will give the user the ability to redefine the model via these parameters.

My requirements was to build a script where I could supply an interior box dimension with a length, width and depth, and the script would spit out a parts outline document that I could just take to a laser cutter, cut out the parts and assemble with 3mm bolts.

OpenSCAD script with a visualization of the finished product
OpenSCAD script with a visualization of the finished product

When I was done building the script I had the basics of what I wanted. But I also added a parameter for the material thickness the panels were cut out of and the slots and bolts would adjust themselves accordingly. I also added a parameter for how thick the tabs are, how long and wide the bolts are,  and the length of the nut is to secure the bolts. I also added a parameter for the number of tabs on the length, width, and depth dimensions individually.  I also designed the code is such a way that I can cut square, circle and polygon holes through individual panels to pass wires and mount buttons and controls on. Finally I coded the ability to toggle the visualization of the design between an assembled box as shown above and the flat design files ready to be cut and assembled.

Rendered design files ready to be sent to a laser cutter.
Rendered design files ready to be sent to a laser cutter.
Parts arranged and cut with a laser cutter.
Parts arranged and cut with a laser cutter.

The box is then assembled with 16mm long 3mm bolts with the nut embedded into the panel and the bolt is inserted from the outside to hold the box together.

IMG_4076

IMG_4075

And finally the assembled box.

Fully assembled plywood box.
Fully assembled plywood box.

And below is an example of a prototyped Raspberry Pi device utilizing this script for an enclosure. As you can see the base of the box is plywood and the top is acrylic. The plywood is nice for a box because if you don’t quite have your holes in the right area ,or you just forgot to add the holes, or you want to mount it on a wall, you can easily drill out a hole.

IMG_4069
Customized parametric box

I made a variant on the parametric box script where the tabs are nested into the receiving panel. This script became the basis of my 3D printer that I upgraded.

Parametric box with tabs nested into the receiving panels.
Parametric box with tabs nested into the receiving panels.