Python script for generating OpenSCAD boxes
by jbernardis, published
I've always admired the laser cut boxes I've seen here and wondered whether or not it could be duplicated with 3D printers. I've seen boxes designed like this, but always for a specific purpose. I wanted the ability to create a box to the dimensions of my choosing.
To this end, I developed a python/tkinter script that allows you to specify box parameters and it generates clean OpenSCAD source code. Cut and paste the code right into OpenSCAD, hit F5, and you're just about ready to print.
Each face of the box is rendered with a separate module so that they can be printed one at a time allowing you to make further modifications, such as openings or mounting brackets.
The python script is standalone - no additional packages are necessary. It runs under python 2.7; it has not been tested with python 3.0.
The generated OpenSCAD program lays the faces out so that they do not overlap, but it makes no attempt to fit them onto your printer bed. That is left to you. Some people prefer plating everything at once; some people, myself included, prefer printing things one at a time.
The paramters you can provide to the program are: 1) internal dimensions - width, height, and depth. 2) how long and wide the tabs are, and how much space there can be between them (the span). You can also specify a "slop" paremeter which is used to make the slots slightly larger so that fit is not an issue. 3) You can specify the height and width of feet that are at the base of the front and rear faces. If either of these parameters is 0, no feet will be generated. 4) You can specify how many latch points are generated. The latch points are where M3 bolts can be inserted into the front and rear faces to hold the box together. You specify the number and whether the are along the top, bottom, or both. By default, these latch points are spaces equally across the width. Alternatively you can manually specify where the latch points should be.
Finally, once you have the parameters set the way you want, you can save that configuration, and then recall it later if you need to make modifications.