Parametric Box Generator

Populate two arrays and generate custom divided storage.

Similar projects worth following
I wanted a box to organize the nozzles for my 3D printer.
Rather than creating yet another one-off box, I made a parametric box generator instead.

Two arrays control the row and column sizes for an arbitrary number of rows and columns.
Every row and column of the array can be a different size.
From that, OpenSCAD generates a storage box with lid.

Both parts print flat with minimal overhangs.
You can also tune: inner wall/outer wall/top/bottom thickness, lid height, and box height.

How To

  1. Open up box.scad in your favorite text editor and OpenSCAD.  Uncomment 'assembly();' and save to see what you are doing.
  2. Modify the arrays until you have the box you want.  
    1. The rows array defines the number and size of each row.  Similarly the cols array defines the number and size of columns.
    2. Make the inner/outer wall thickness an even multiple of your nozzle size for best results.
    3. Wall thickness currently is subtracted from the cell size.  For example, if you want a 7mm opening and are using 0.8mm walls, that array element would then need to be 7.8mm.
    4. Boxes with an odd number of columns generate better hinges.  An even number will result in one end being un-terminated.
  3. Comment out 'assembly();', uncomment 'box();', save, render, export to stl.  
  4. Comment out 'box();', uncomment 'lid();', save, render, export to stl.  
  5. Slice.  I would suggest enabling 'combing' and the hinge does better with a relatively low layer height (like 0.1mm for a 0.4mm nozzle). 
  6. Print both parts, press in a bit of wire for a hinge pin, and enjoy your divided box.

x-openscad - 5.19 kB - 03/23/2019 at 17:18


sla - 577.86 kB - 03/23/2019 at 17:18


sla - 815.74 kB - 03/23/2019 at 01:41


  • Bumps.

    Daren Schwenke03/23/2019 at 15:39 0 comments

    The two bumps (spheres in the code) which are the latch and snap it closed could use to be slightly taller.  

    That's a bending interface and the force applied crosses layer lines, so a delicate balance must be struck. 


    Fixed.  New source and rendered files are up.


  • Hinge issue.

    Daren Schwenke03/22/2019 at 21:56 0 comments

    I didn't make the hinge area thick enough and it didn't hold together after printing.

    Fixing it.


    Hinge is fixed.  Also sorted the outer wall bug and made some other tweaks.

    Updated the files.  Reprinting.

    This is actually a pretty small box, so the hinge isn't nearly as large as it looks.


  • Two bugs.

    Daren Schwenke03/22/2019 at 19:43 0 comments

    • The outer wall has to be set to subtract 1/4 of the inner wall value, to be the right value.  So to get a 0.8mm outer wall, with a 0.8mm inner wall, you have to set it to 0.6mm.
    • You need an odd number of 'rows' to have the hinges closed on both ends.

View all 3 project logs

Enjoy this project?



Dan Maloney wrote 03/25/2019 at 15:33 point

Nice job. I'm going to have to start playing with Open SCAD - I could use a bigger version of such a box to organize RF adapters.

  Are you sure? yes | no

Daren Schwenke wrote 03/25/2019 at 15:48 point

Thanks.  If you run into any stumbling blocks, feel free to ask.

OpenSCAD is sometimes a little odd to write for in that by the time the execution of the code happens, variables are essentially read only.  So looping over stuff and carrying the modified things forward sometimes requires recursion where you don't think you would normally need it.  Like here..  :)

Other than that, it's pretty straightforward and your 3D models can be version controlled to boot.  For a programmer, I think it's perfect.

  Are you sure? yes | no

Ted Yapo wrote 03/23/2019 at 15:08 point

Very nice! I made some dividers to use with Altoids tins for storing flies (the ersatz insects used to catch fish, not the real ones) at one point, but it would be nice to be able to make boxes in any size.

  Are you sure? yes | no

Daren Schwenke wrote 03/23/2019 at 15:54 point

Thank you.  It was one of my best attempts thus far at proper recursion in OpenSCAD, but then it got a little messy. Thought about doing dividers but that meant my nozzles wouldn't stand up.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates