OpenSCAD Gives You Parametric Boxes

OpenSCAD is one of the most powerful 3d modeling applications around. Its beauty is in its simplicity; if you need a box, you can just write the code for a box. If you need some bit of plastic to keep your 3D printer running, you can just write the code for that bit of plastic. Like all programming languages, OpenSCAD is only really powerful if you have a huge back-catalog of various components ready for reuse. That’s where [Mark]’s library for hinged boxes comes in handy. Every type of box you would ever want to create, from boxes with covers, magnet closures, or cases for your glasses is easily accessible with just a few lines of code.

The work presented here is an OpenSCAD script to generate two-piece hinged boxes, with rounded corners, a lid, interlocking rims, and optional snap fit, magnet, or screw closures. As you would expect from OpenSCAD, everything in this script is parametric. You can change any measurement or simply delete entire sections of the box.

The included examples consist of a small mini-Altoids tin-sized ‘Bee Box’ with a snap-fit lid. All of the relevant dimensions of the snap-fit lid are variables. Other examples include an eyeglass case and a box for small parts storage that interlock. If you have a few rolls of filament, a lot of time on your hands, and want to organize your workbench, you could do worse than checking out a few of these OpenSCAD boxes.

37 thoughts on “OpenSCAD Gives You Parametric Boxes

  1. I am a heavy user of OpenScad. So heavy that I have spent the time to develop an Excel front end for it. To create a mtodule you describe it in a few rows and columns that take care of object name, type, rotations, color, transparency, and translation. The excel macro takes care of making the openscad file. Module hierarchy is supported and, since it’s Excel, all the cell formula and references are there for you to use. I also embed the $t variable and can do animations in a flash!

  2. Great. This could possibly come in really handy just at the right time. I will need a box in a few days to throw a µC and all sorts of thing in, but I don’t know how big it needs to be yet, so this looks perfect for me. I was way too lazy to design one myself and would’ve went to the local diy shop.

  3. I keep hearing how amazing OpenSCAD is, but I am familiar enough to know that you need to know how to code to use it.

    I have written basic Python scripts for just simple math for astronomical gear trains, and I can natively program in G-Code, but I would love an open source parametric modeler that worked similar to Fusion 360 without having to learn how to code in another fashion to create when I am already adept in creating solids.

    I don’t mean to hurt anybody by asking here but could anyone recommend something as powerful as OpenSCAD but without coding? It seems like everything either goes proprietary and easy to use but a pay model however everyone who wants open source just has to settle to learn how to code to do anything and it’s just really tiresome.

    1. See my comment above about my Excel front end for OpenScad and this project I added on hackaday.io https://hackaday.io/project/164331-rapid-3d-models-with-excel-and-openscad

      No coding needed at all. typing, yes but even with a more powerful CAD program you will have to type in sizes and other properties Also with the Changer form you can change properties on the fly and see the effect in Openscad in real time because it can reopen the file and recreate the model whenever it changes

    2. One option is Matt Meeker’s Antimony. It is node based, uses Python formulas, and any field in any component can be accessed via a ‘component.field’ variable name. It’s pretty cool, but the dev only has official Mac releases, though others have created releases for other systems.

  4. ‘OpenSCAD is one of the most powerful 3d modeling applications around.’ I honestly don’t know anyone in industry who uses it and really only hear about it on this website. It seems like CAD that is favored by programmers, but it feels really dated honestly. I guess if you like parts built from scripts knock yourself out…It would be nice to hear about alternatives on this website, since Hackaday seems like it is basically shilling for this software.

    1. I honestly do agree with your opinion… being a Mech. Engg. I find OpenSCAD a pain to work with.. and I do agree more programmers/ coders find it easier to work with SCAD.
      I have tried using it and I just could never get the hang of it.. Creo, Pro-E, Catia, Solidworks, F360..I have worked with.. and some how find it intuitive to draw a box than to write I want a box…

      Just my opinion!

      1. “draw a box than to write I want a box” is right on. A better comparison would be adding fillets or something, which is _much_ easier to draw than to script, at least in vanilla OpenSCAD. Free-form objects, organic shapes, etc. Getting the squash on an oval right by dragging is easier than figuring out the scaling ratio in the X axis. That’s where GUI modelers shine.

        (But e.g. https://github.com/clothbot/ClothBotCreations/blob/master/utilities/fillet.scad)

        What’s easier to do in OpenSCAD is to make a hundred boxes each rotated three degrees. Rather than cut/paste until your mouse finger is blue, you just type for(){}.

        Or if you want to quickly re-size or tweak a design, import sub-assemblies from previous projects, etc. Or extend the language to make adding fillets easy, or generate cookie cutters from DXFs automatically, or… In short, all the stuff that code is good at.

        It’s easier to type “2+2=” into a calculator, but if you’re looking at millions of data points, you need to learn to code or else your calculator finger will get sore.

        Horses for courses. Tools for jobs.

        1. What would be good is some sort of simple gui that you can use to generate openSCAD code graphically. Maybe even a Web ui for it. There are times it would be very useful

          1. I believe it can interpret openscad code, but I don’t think it can generate it, which would be much handier. If I could do that, I could use the gui to generate the more organic shapes or even a rough prototype, and then edit the generated scad file for the details

        2. “What’s easier to do in OpenSCAD is to make a hundred boxes each rotated three degrees. Rather than cut/paste until your mouse finger is blue, you just type for(){}.”

          If done a lot, that would be a dialog box. QUANTITY:100 STEP:3 in whatever default angle measures are being used.

  5. There are advantages and disadvantages to programmatic modelling. It takes a lot of work to do your initial setup, but once you have your model, it is FAR easier to make modifications to it.

      1. Well, parametric design and programmatic design have a lot of overlap, at least. I am referring to the more general case of designs that are generated by code, instead of by a person drawing it on a screen. Parametric is referring to thew ability to modify a design by changing parameters. In most cases they are the same thing, but it is possible to have programmatic designs that are can’t easily be parameterised, and have interfaces that allow you to parameterise a design that was originally done with more traditional design rules (although there would be code involved in that at some level, but the basic design itself is still done the organic way)

      1. “Workarounds” is a strange thing to call functions that other people have written in a programming language that extend its functionality.

        That’s like saying it’s too bad that databases aren’t supported in X86 assembly language without a workaround. Granted, it’s quite a workaround. :)

        There are a fillet libs out there. I use a variant on this one sometimes: https://github.com/clothbot/ClothBotCreations/blob/master/utilities/fillet.scad
        Also: https://www.thingiverse.com/thing:2461392

        The real beauty of the software approach is that its extensible and can build easily on the work that others have done, and sharing is trivial/free. This is OpenSCADs killer feature.

  6. I think the worst part of OpenSCAD (which I use a lot) is that it’s not multi-threaded. Some complex models that I have take a long time to render even though I’ve ensured that they don’t have too many extra faces and I bet it could utilize my desktop’s eight cores better. They should do Mozillas to the rendering engine and rewrite it in Rust. ;) Seriously though, I really like what they did with Stylo (CSS style system) and I wonder if similar worked for OpenSCAD. It doesn’t have to be done in that language of course but that level of parallelism would be nice indeed.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.