Hey! This thing is still a Work in Progress. Files, instructions, and other stuff might change!

Ultimate Box Generator

by pynej, published

Ultimate Box Generator by pynej Oct 19, 2017


Design Tools



Ultimate Box Generator by pynej is licensed under the Creative Commons - Attribution license.

Liked By

View All

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag


Thing Statistics

1588Views 322Downloads Found in DIY


Version 3.0 updated updated Nov 17, 2017.

This was originally a simple modification to https://www.thingiverse.com/thing:15113 with some code from https://www.thingiverse.com/thing:26596. It has since grown far beyond those roots. Above are just a few examples of the myriad types of containers it can generate.

In short this is a container generator that you can customize with over 50 parameters to generate all sorts of containers with lids, compartments, and mesh sides as you see fit. I am still actively developing it as I see new uses and can incorporate requests if you can describe what your looking for. You can also just print a simple box as well.


Current Options

Note that there are many parameters and variations. I have tested most options but there are innumerable configurations and its totally possible to generate boxes that aren't printable.

Box Types

  • Single Box.
  • Repeating Box with compartments in X and/or Y direction.
  • Cylinder box or box with curved bottom area to hold bits. (Partial)
  • You can also combine boxes to generate more complex containers with multiple sizes of compartments and depths that fill flush to lid. This is a larger ambition and will probably become a separate project eventually and isn't designed for lids. (Partial)

Lid Types

  • Standard slid on top.
  • Slide in form side.
  • Hinged Lid.
  • Snap on top. (Uses a few inner snap to make a pressure hold.
  • Stackable boxes. Bottom of one box slides into top of another.

Mesh Types

  • None/Solid.
  • Empty, optional rounded corners. (Use and mesh with a high strut_gap.)
  • Single Direction
  • Cross Hatch (Two sets Rotated by 90 degrees.)
  • Spines pivoted around the vertical. (Ie to do 80 and 100 degree spines.)
  • Diagonal across opening. (Calculate angle automatically cover to corner.)

Internal Frames

  • None
  • Curved for circular bits.
  • Angles for hexagon tiles.
  • Uneven bottom so bits don't lay flat and can more easily be grabbed. (Partial, Not Tested)
  • Custom. (You can add make_wall calls in the main code to add custom walls anywhere you need.)

Other Options

  • Repeat compartments.
  • Snaps so boxes stay closed.
  • Openings in sides to shave materials.
  • Thumb gripes to ease opening.
  • Openings in compartments for dropping bits in.
  • Support for easily surpassing individual walls from the generated structure.

Future Features

  • More complex box generation with multimedia sizes of compartments.
  • Board Game Inserts.
  • Internal structure options.
  • Configurable Thumb holes for extracting cards and bits easily.
  • Circular containers and rounded corners.
  • Configurable options for insetting text cutouts into walls or lid.
  • Support for custom wall mesh via custom module.

Depending on the gaps in the windows it looks like I can get ~10-30% less material used while retaining integrity but prints may take longer.


Customizing Boxes

You can just download this file and edit it directly to make custom boxes but if you want to update to a new version in the future you will have issues. Instead you can create a new scad file in the same folder as put your customizations there instead. That second file is the one you will run and the first line needs to be include <Ultimate_Box_Generator.scad>;.

Doing it this way then in the future you can simply replace the Ultimate_Box_Generator.scad file and re-run your custom file. But be advised that defaults in the Ultimate_Box_Generator.scad file might change though so make a copy first incase you need to add any more overrides.


include ;


All Settings

// General Settings
comp_size_deep = 12; // Depth of compartments
comp_size_x = 50; // Size of compartments, X
comp_size_y = 35; // Size of compartments, Y
wall = 2.5; // Width of wall, see internal_wall below for alternate inner wall size.
repeat_x = 1; // Number of compartments, X
repeat_y = 1; // Number of compartments, Y
tolerance=.15; // Tolerance around lid. If it's too tight, increase this. If it's too loose, decrease it.

// Supress individual walls.
supress_walls_x=[]; // These are the walls running along the X axis. It should be an array of size [repeat_y-1][repeat_x].
supress_walls_y=[]; // These are the walls running along the Y axis. It should be an array of size [repeat_x-1][repeat_y].
// Example for repeat_x=4, repeat_y=3:

// Parts to render
show_box=true; // Whether or not to render the box
show_lid=true; // Whether or not to render the lid. To make open boxes with no lid set show_lid=false and lid_type=0.

// Mesh Settings
// To make rounded corners and no mesh use any mesh_type > 0 and set strut_gap to a high value.
// 0: No mesh, solid wall.
// 1: Single direction mesh.
// 2: Two direction cross mesh and 90 degree angle to eachother.
// 3: Two direction mesh but mirrored around 90 axsis instead or rotated 90 degrees.
// 4: Calculate angle across the diagonal of each opening. You will also want to change strut_gap to a large number and set strut_count_min=1.
mesh_type=0; // Mesh type, see above.
mesh_rotation=0; // 0-90 degrees.
mesh_corner_radius=0; // Leave a radius around each corner of the mesh. May hep with bridges.
mesh_alt_rotation=mesh_rotation; // Alternate rotation for top and bottom faces.
mesh_do_sides_x=true; // Include mesh on each side along the X axis.
mesh_do_sides_y=true; // Include mesh on each side along the Y axis.
mesh_do_bottom=false; // Include mesh on bottom plate.
mesh_do_top=true; // Include mesh on top piece.
mesh_do_interior=false; // Include mesh on inner walls.
mesh_inset_padding=wall; // Leave some solid material before building strut frame. Anything less then wall will likely fall apart.
strut_width=wall*2; // Width of each strut, 0=hollow.
strut_gap=wall; // Width of the air gap between each strut. 0=fine air gaps.
strut_count_min=0; // Optinal minimum number of struts regardless of size calulations.
alt_strut_width=strut_width; // Width of struts going the other directions.
alt_strut_gap=strut_gap; // Width of gap going the other direction.
alt_strut_count_min=strut_count_min; // Optinal minimum number of struts regardless of size calulations.

// Lid Settings
// 0: Flat lid sits on top with a border.
// 1: Lid that slides off in the x direction.
// 2: Lid with a snapped in hinge that rotates open
// 3: Lid that snaps down onto the box. Also need to change lid_height to around 1.5mm.
// 4: Stackable version of cover 1 there boxes slide into one another. You will need one cover for the last box. (Not tested)
lid_type=1; // Lid type, see above.
has_thumbhole=false; // Add gripping locations for easy opening.
has_coinslot=false; // Add slot in the top for dropping in components.
has_snap=true; // Add small ridges or snaps to lids to help keep them closed.
coinslot_x=20; // Size in X direction
coinslot_y=2.5; // Size in Y direction
z_tolerance=0; // Z tolerance can be tweaked separately, to make the top of the sliding lid be flush with the top of the box itself.
extra_bottom=.15; // Extra bottm wall height to fit type 4 slider.
hinge_inset=.75; // Size of the hinge connection.
snap_inset=.25; // Amount of overhang for snaps to snap into place.
snap_tolerance=tolerance; // You may need to add tolerance around lid and snaps to let them move freely.
lid_offset=3; // This is how far away from the box to print the lid
lid_height=wall*2; // Height of lid. Must be greater than wall width for a lid_type=0 lid to work. On Lid 3 is the depth of the inset snap.

//Internal Structure (You may need to turn off mesh_do_sides or mesh_do_bottom for good results.)
// You can also use make_wall() to menaully add your own walls.
// 1: Rounded bottom frame.
// 2: Hexegon bottom frame. (To make this shape perfect set comp_size_deep to the width between to edges of the tile and set comp_size_x or comp_size_y to this this: comp_size_deep / sqrt(3)*2.
// 3: Rough bottom for make bits sit unevenly.
internal_type=0; // Internal structure, see above.
internal_rotate=false; // On lid axis or rotate to opposite.
internal_size_deep=comp_size_deep/2; // How far into the box to start the internal structure. Should be comp_size_deep/2 for type 1 and 2 or around wall for 3.
internal_wall=wall; // Custom size for internal walls.



11/07/2017 - Simplified internal math with functions and pre-calculations. Added Stackable boxes. Added function to add custom walls. Improved mesh performance. Added support for generating multimedia boxes of different sizes in one program by passing override parameters to the functions. Renamed project and updated documentation.
11/07/2017 - Added two arrays that can be used to suppress internal walls and make larger compartments or compartments of varying sizes.
10/27/2017 - Added some basic options for adding extra internal structures to a compartment. You can adjust in the make_box_internal function. Other fixes for the file uploaded yesterday.
10/26/2017 - Added Mesh type 4 that calculates the angle along the hypotenuse for spines. Also added slight snaps for the slide in lid.
10/24/2017 - Added Mesh type 3, this pivoted around the vertical axis instead of rotating 90 degrees. Can be useful for creating steeper or shallower angles which may be easier to print. Added a lid types 2 and 3. 2 will snap into the box with a small inset lip. 3 will create a roller at one end and flip open and closed.
10/23/2017 - Major update and rewrite, removed large chunks or repeated code and moved logic into modules. Better documentation and parameters, fixes for mesh calculation issues, new modes.
10/20/2017 - Updated with fixes for lid 0 and some mesh layout errors.

More from DIY

view more

All Apps

Upgrade this Thing with Thingiverse Apps

No results.

Hi, I'm not sure the proper place for this, but I found an issue with your code.
I was trying to make a box with multiple compartments (repeat x or y >1), have internal type 1 (rounded), and suppress some of the inner walls to make one compartment be larger than the others.

Everything worked fantastically, except the rounded bottoms in the larger compartment. There are gaps in the rounded bottom where the suppressed internal wall would have been. I had a look through the code and made the modification below in the make_box_internal() module:

Line 375:
Original: linear_extrude(internal_rotate ? comp_size_y: comp_size_x)
Edit: linear_extrude(internal_rotate ? comp_size_y + internal_wall : comp_size_x + internal_wall)

This fixed my issue. Thanks for the awesome plans!

Running them with the following seamed to help on mine a lot, lot less time extruding and retracting filament then what I was doing.

strut_width=wall; // Width of each strut, 0=hollow.
strut_gap=wall4; // Width of the air gap between each strut. 0=fine air gaps.
alt_strut_width=strut_width; // Width of struts going the other directions.
2; // Width of gap going the other direction.

Nice! Yeah, I expect prints would take WAY longer (at least on my machine), but there's a lot of potential for beautiful designs here. Great contribution! :)