Ultimate Box Generator by pynej 3d model
Warning. This content is not moderated and could be offensive.
revolver
3dmdb logo
Thingiverse
Ultimate Box Generator by pynej

Ultimate Box Generator by pynej

by Thingiverse
Last crawled date: 3 years ago
Version 3.6.0 updated November 17, 2020.Download both files and copy/edit the template to make your boxes.
Welcome to the Ultimate Box Generator! This is a very complex project that will as its name suggests, create boxes for you. And by boxes I mean boxes, containers, compartments with lids, boxes with many smaller compartments within them, and on and on. This tool is very powerful, but also rather complex. There are over 60 custom variables that can be tweaked with no programming experience, and the possibility of make complex inserts and boxes with varying size compartments with a bit of OpenSCAD scripting.
This project was originally inspired by https://www.thingiverse.com/thing:15113 with some code from https://www.thingiverse.com/thing:26596. It has since been rewritten completely and grown far beyond those roots. The screenshots above are just a few examples of the myriad types of containers that can be generated with this tool.
With the 3.3.x version there is now a template file that you should copy and modify for you boxes instead of editing the variables in the box generator file directly.
This project represents hundreds of hours of coding, tinkering, and testing on my part, so please use it, share it, and feel free to drop me a tip if you like. I am still actively developing features so feel free to make suggestions in the comments.
Note: mesh_do_sides_x and mesh_do_sides_y where replaced. Please see the example and update as needed.Note: lid_type=0 is now lid_type=5.
Features
Current Options
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 or structurally sound.
Box Types
Single Box.
Repeating Box with compartments in X and/or Y direction. Walls can be suppressed to make larger compartments.
Cylinder, hexagonal, or curved bottom and/or sites to hold bits.
You can also combine boxes to generate more complex containers with multiple sizes of compartments and depths that fit flush to lid. (This is done with calls to make_internal_box or by using complex_box but requires OpenSCAD scripting.)
Lid Types
Standard slide on top.
Hinged Lid.
Snap on top. (Uses a few inner snaps to make a pressure hold.
Stackable boxes. Bottom of one box slides into top of another.
Mesh TypesSee the examples section for examples and potential material savings.
Solid walls.
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 corner to corner.)
One large opening in wall, optional rounded corners. May need supports on vertical walls.
Honeycomb walls. (Adjustable size and spacing.)
Internal Structure
None
Curved for circular bits on sides or bottom.
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 or use other OpenSCAD code in the template to add custom structure.)
External Structure
Top hole/token slot
Sides can be omitted with inset, rounding, etc
Text Options
Text can be applied to the sides, top, and bottom.
Multiple lines can be provided manually but lines won't wrap automatically.
Text can be raised or inset, and the font, size, and angle can be adjusted.
With multiple compartments the text can be changed for each compartment.
Depending on the overhang, you won’t need supports. If you do a cutaway on a vertical wall you may.
Other Options
Repeating compartments.
Snaps so boxes stay closed.
Openings in sides to save materials.
Thumb gripes to ease opening.
Openings in compartments for dropping bits in.
Support for easily surpassing individual walls from the generated structure for larger compartments.
Rounding on box edges and/or internal corners.
Tools for make complex boxes of smaller boxes.

Future Features
More complex box generation with varying sizes of compartments. (Partial with make_complex.)
Support for custom wall mesh via custom module.
Flip lid like the hinged one but with an external hinge and flush top.
Rendering speed improvements. (Partial)
Regarding wall mesh's and text, some configurations may needs supports but many can be printed without. Also using a mesh can save from 10 to 30% total martial on the print compared to a solid wall at the cost of some print speed. Regarding print speed, make sure your retraction distance isn't to high.
Instructions
Customizing Boxes
To create custom boxes, download both files to the same location and then make a copy of the Box Template.scad file to work on. Edit this file as needed updating variables and adding code to create custom structure. When you are satisfied with the box save it and use the Render and then Export as STL toolbar buttons to make the solid model.
By doing it this in the future you can simply replace the Ultimate_Box_Generator.scad file and re-run your custom file to receive new options and fixes without having to edit anything you have customized.
All Settings
// Parts to render. To do more complex opperations disable these and manually call make_box() and make_lid() instead.
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=5.
// 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.
// Box Rounding
box_corner_radius=0; // Add a rounding affect to the corners of the box. Anything over wall will cause structure and lid problems.
box_corner_radius_axis=true; //[true, true, true] Apply outer rounding on specific axis. Selecting two forces the theird as well. [X, Y, Z]
internal_corner_radius=0; // Add a rounding affect to the inside.
mesh_corner_radius=0; // Leave a radius around each corner of the mesh. May hep with bridges.
corner_fn=30;
// 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:
//supress_walls_x=[[1,0,1,1],[0,1,0,1]];
//supress_walls_y=[[1,0,1],[0,1,1],[1,1,1]];
//supress_sides=false; // [X, Y, X, Y] Cutout/supress some sides. this may behave baddly with compartments or mesh.
//supress_sides_radius=wall; // Add a rounding to the cutout.
//supress_sides_offset=0; // 0, wall, [X, Y, Z] adjsut the coutout in all directions. + to grow, - so shrink
//supress_sides_fn=30;
// 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.
// 5: No mesh, empty wall.
// 6: Honycomb. Also set strut_width=wall/4 and strut_gap=wall*2. To big of a strut_gap may fail to print. Other shapes can be generated with mesh_fn and reducing mesh_inset_padding may help.
mesh_type=0; // Mesh type, see above.
mesh_rotation=0; // 0-90 degrees.
mesh_alt_rotation=mesh_rotation; // Alternate rotation for top and bottom faces.
mesh_do_sides=true; //[true, true, true, false] Include mesh on each side along axis. [X, Y, X, Y]
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/2 will likely fall apart.
mesh_fn=mesh_type == 6 ? 6 : 40; // Complexity of curves in mesh's, increese for smoother curves.
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.
mesh_overflow=0; // Extra rows to add to the mesh. For example in the Honeycomb partial hexegons will be created along the edges.
// Lid Settings
// 0: No Lid. top may be rounded and can cause other rendering changes.
// 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)
// 5: Oversized lid sits on top and has sides that extend down. (Needs snapp support)
lid_type=1; // Lid type, see above.
has_thumbhole=true; // 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=5 lid to work. On Lid 3 is the depth of the inset snap.
lid_fn=40; // Increese if printing thicker walls.
lid_alt_offset=false; // Move lid in X instead of Y for printing.
//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 manually 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. (Partial)
// 4: Verical rounding on cordner. Set internal_size_deep to comp_size_deep and internal_size_circle to the shortest comp_size for a circle.
// 5: Vertical hexegon. Retulst may varry.
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-2, wall for 3, or comp_size_deep for type 4-5.
internal_size_circle=internal_type==1 ? internal_size_deep : internal_size_deep * 2 / sqrt(3); // Use this calculation, or the shorter comp_size for type 4-5.
internal_fn=internal_type==1 || internal_type==4 ? 60 : 6; // Complexity of internal curves, may need to increase for larger or smoother curves.
internal_wall=wall; // Custom size for internal walls.
// Text Settings
// 0: None.
// 1: Cutout. Remove material formt he wall.
// 2: Raised. If a mesh is ued part of it is filled in to hold the text. Lids 0 and 3 are printed upside down by default. With this option used they will require supports regardless of the orrientation printed.
text_type=0; // Text type, see above.
text_depth=wall/6; // Distance to cutout text or raise it. User wall to cut through.
text_size=5; // Font Size.
text_font="Courier New:style=Bold"; // Use Hepl -> Font List to see options.
text_message="Red Player"; // Message Text, or use ["Line 1", "Line 2"] for multiline.
text_message_compartments=false;//[["AA", "BB", "CC"], ["AB", "BC", "CD"]]; // Custom text for compartments in top or bottom. Also support multiline as [[ ["A", "B"] ]].
text_sides=true;//[true, true, true, false]; // Sides to put text on, [X, Y, X, Y]
text_top=true; // Put Text on the top.
text_bottom=false; // Put Text on the bottom.
text_rotation=0; // Rotate the top and bottom text by X degrees. 90 will rotate from the X axis to the Y axis.
text_offset=0; // Text is verticaly centered in the wall. This may look "off" due to casing or hanging tails. You can manually adjust the vertical alignment with this setting.
text_fn=30; // Complexity of the letters, may need to increese with larger fonts.
text_backdrop_scale=[.9, 1.5]; // Font size scaleing used on the backdrop when text_type=2 is used on sides with a mesh.
// Complex Structure
make_complex_box=false; // Use an array of objects from complex_box to create many smaller boxes within the larger box.
internal_grow_down=true; // If set compartments will be extruded into the larger box from the top to make a flush surface. (May make a model that uses a lot of material.
internal_empty_bottom=false; // If set the area blow each box will be empty. This will not be printable on a FDM printer unless supports are included internally but still may save material and print time.
Other
Updates
11/17/2020 - Added supress_sides and related settings to optimal omit walls form box.11/17/2020 - Fixed internal_corner_radius with supress_walls11/17/2020 - Fixed text_type=2 with box_corner_radius10/18/2018 - Added box_corner_radius_axis to control what axis gets the rounding.10/18/2018 - Minor fix for box_corner_radius on lids.10/17/2018 - Minor fix for box_corner_radius on lids.10/12/2018 - Fixes for text on lid, added backdrop for text on mesh, created rounding section, changed lid_type=0 to lid_type=5.10/11/2018 - Major rendering speed improvements. (More ongoing)10/9/2018 - Added a mesh feature to create honeycomb walls. Use strut_width, strut_gap, and mesh_overflow to customize.10/2/2018 - Replaced mesh_do_sides_x and mesh_do_sides_y with mesh_do_sides=[x1, y1, x2, y2]. You will need to adjust your custom variables.10/2/2018 - Added complex_box feature and support for creating multiple complex boxes in a larger box and positioning them.10/2/2018 - Added internal rounding and vertical oriented internal structures.10/2/2018 - Added feature_fn variable to control the detail of curves and help with rendering speed.9/25/2018 - Added support for multi-line text areas.9/24/2018 - Fix for Hinged cover snap.9/24/2018 - Added support for including a line of text on the sides, top, or bottom. The bottom text can be read from looking into the box. Text can be raised or cut into the wall. Top and bottom text can be specified for each compartment.9/24/2018 - Added a template for creating boxes and definition in a separate file to updates to the generator can be easily loaded into a project.9/24/2018 - Fix for solid covers on on boxes with repeating compartments.9/24/2018 - Fix for internal structure not extending as expected if there were suppressed walls causing voids.9/24/2018 - Fix for internal structure rendering in places it shouldn't where there was a suppressed wall.9/24/2018 - Added a option for including rounded corners on the boxes.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.
Examples
Regarding Mesh Options
I ran a series of tests on a simple box with lid with various Mesh options for comparison. These slicer tester all used the same settings and generated meshes on the sides and top but not the bottom. (This is how I usual print things, the more solid base help ensure the model is rigid and dimensionally accurate.)
Test Settings
Print Speed: 75mm/s
Layer Height: .2mm
Retraction Distance: 1.5mm (This was way to high be default at 6.5mm.)
Infill: 13%
Supports: Where needed (Test 3 & 4)
Results
You can see blow that the various mesh options all save a noticeable amount of material and don't hinder print speed. It is of course possible to create mesh's that aren't as efficient but this gives a good summary of the possible benefits.
Test
mesh_ype
Settings
Material Used
Print Time
Material Saved
Ctl
Solid

67g
4:34

#1
2: Diagonal
strut_width=wall*2; strut_gap=wall*2; mesh_rotation=45;
49g
4:00
27%
#2
2: Square
strut_width=wall; strut_gap=wall*2;
51g
4:10
24%
#3
4: Split
strut_width=wall*2; strut_gap=comp_size_deep; strut_count_min=1; mesh_inset_padding=wall*2;
49g
4:00
27%
#4
5: Hollow
mesh_corner_radius=comp_size_y/4; mesh_inset_padding=wall*2;
44g
3:23
34%
#5
6: Honeycomb
strut_width=wall/2; strut_gap=wall*4; mesh_inset_padding=wall/2;
48g
4:00
28%

Tags