A ground-up port (with a few extra features) of the stock [gridfinity](https://www.youtube.com/watch?v=ra_9zU-mnl8) bins in OpenSCAD. Open to feedback, because I could not feasibly test all combinations of bins. I tried my best to exactly match the original gridfinity dimensions, but some of the geometry is slightly incorrect (mainly fillets). However, I think they are negligible differences, and will not appear in the printed model.
The printable holes allow your slicer to bridge the gap inside the countersunk magnet hole (using the technique shown [here](https://www.youtube.com/watch?v=W8FbHTcB05w)) so that supports are not needed.
For best results, use a version of OpenSCAD with the fast-csg feature. As of writing, this feature is only implemented in the [development snapshots](https://openscad.org/downloads.html). To enable the feature, go to Edit > Preferences > Features > fast-csg. On my computer, this sped up rendering from 10 minutes down to a couple of seconds, even for comically large bins.
These are the parameters that define the type of bin being constructed. Therefore, they impact everything that does not relate to compartments, such as the base and the outside wall.
Parameter | Range | Description
--- | ----- | ---
`gridx` | {n>0\|n∈Z} | number of bases along the x-axis
`gridy` | {n>0\|n∈Z} | number of bases along the y-axis
`length` | {n>0\|n∈R} | size of the square bases in millimeters, default 42
`gridz_define` | {0,1,2} | • (0) Unit height: `gridz` is the height in units (7mm increments). The stock bins have a unit height value of 2, 3, or 6. The overall height of the bin is `7*u + 3.8` millimeters, where the 3.8 is the height of the top lip. <br> • (1) Internal height: `gridz` is the height from the bottom of a compartment to the top of the tab in millimeters. This is effectively the maximum height of an object that can fit inside the bin. <br> • (2) External height: `gridz` is the overall height of the bin, from the base to the upper lip fillet. This is effectively how deep a drawer must be to fit the bin.
`enable_holes` | boolean | toggle holes for magnets and M3 screws on the base of the bin
`enable_hole_slit` | boolean | toggle the printable countersunk hole cut
`enable_zsnap` | boolean | have the bin increase in height until it matches the nearest 7mm increment. Useful if a bin needs to be a minimum internal size to fit a part (i.e. `gridz_define == 1`) but you still want the bin to fit within the sizing standards of the gridfinity system
`enable_lip` | boolean | toggles the lip at the top of the bin that allows for bin stacking
Initializes the top part of the bin (walls and solid section). All bins have to use this module, and have the compartments cut out from it.
Parameter | Range | Description
--- | ----- | ---
`gridx` | {n>0\|n∈R} | number of grid units along X
`gridy` | {n>0\|n∈R} | number of grid units along Y
`height` | {n>0\|n∈R} | height of the bin, in millimeters (but not exactly). See the `height()` function for more info.
`height_internal` | {n>0\|n∈R} | height of the internal block. Can be lower than bin height to save filament on custom bins. default of 0 means use the calculated height.
`length` | {n>0\|n∈R} | length of one unit of the base. default: 42 (The Answer to the Ultimate Question of Life, the Universe, and Everything.)
```
// Example: generate a 3x3x6 bin with a 42mm unit size
`gridz` | {n>0\|n∈R} | bin height. See bin height information and "gridz_define" below.
`gridz_define` | {n>0\|n∈R} | determine what the variable "gridz" applies to based on your use case. default: 0. <br> • (0) gridz is the height of bins in units of 7mm increments - Zack's method <br> • (1) gridz is the internal height in millimeters <br> • (2) gridz is the overall external height of the bin in millimeters
`enable_lip` | boolean | if you are not stacking the bin, you can disable the top lip to save space. default: true
`enable_zsnap` | boolean | automatically snap the bin size to the nearest 7mm increment. default: true
```
// Example: height for a 6 unit high bin
height(6);
// Example: height for a bin that can fit (at maximum) a 30mm high object inside
Generates the bases for bins. Has various different hole styles, and can be subdivided.
Parameter | Range | Description
--- | ----- | ---
`gridx` | {n>0\|n∈R} | number of grid units along X
`gridy` | {n>0\|n∈R} | number of grid units along Y
`length` | {n>0\|n∈R} | length of one unit of the base. default: 42
`div_base_x` | {n>=0\|n∈Z} | number of divisions per 1 unit of base along the X axis. (default 1, only use integers. 0 means automatically guess the division)
`div_base_y` | {n>=0\|n∈Z} | number of divisions per 1 unit of base along the Y axis. (default 1, only use integers. 0 means automatically guess the division)
`style_hole` | {0, 1, 2, 3} | the style of holes in the bases <br> • (0) No holes <br> • (1) Magnet holes only <br> • (2) Magnet and screw holes - no printable slit <br> • (3) Magnet and screw holes - with printable slit
```
// Example: generate a 3x3 base with a 42mm unit size and clean magnet holes
`n_divx` | {n>0\|n∈Z} | number of compartments along X
`n_divy` | {n>0\|n∈Z} | number of compartments along Y
`style_tab` | {0,1,2,3,4,5} | how the tabs for labels are generated. <br> • (0) Full tabs across the entire compartment <br> • (1) automatic tabs, meaning left aligned tabs on the left edge, right aligned tabs on right edge, center tabs otherwise <br> • (2) left aligned tabs <br> • (3) center aligned tabs <br> • (4) right aligned tabs <br> • (5) no tabs
`enable_scoop` | boolean | toggles the scoopy bit on the bottom edge that allows easy removal of items
```
// Example: this generates 9 compartments in a 3x3 grid, and all compartments have a full tab and a scoop
Cuts a single compartment into the bin at the provided location with the provided attributes. The coordinate system for compartments originates (0,0) at the bottom left corner of the bin, where 1 unit is the length of 1 base. Positive X and positive Y are in the same direction as the global coordinate system.
Parameter | Range | Description
--- | ----- | ---
`x` | {n>=0\|n∈R} | X coordinate of the compartment (position of left edge of compartment)
`y` | {n>=0\|n∈R} | Y coordinate of the compartment (position of bottom edge of compartment)
`w` | {n>0\|n∈R} | Width of the compartment, in base units (1 unit = 1 `length`)
`h` | {n>0\|n∈R} | Height of the compartment, in base units (1 unit = 1 `length`)
`t` | {0,1,2,3,4,5} | how the tabs for labels are generated for this specfic compartment. <br> • (0) Full tabs across the entire compartment <br> • (1) automatic tabs, meaning left aligned tabs on the left edge, right aligned tabs on right edge, center tabs otherwise <br> • (2) left aligned tabs <br> • (3) center aligned tabs <br> • (4) right aligned tabs <br> • (5) no tabs
`s` | boolean | toggles the scoopy bit on the bottom edge that allows easy removal of items, for this specific compartment
Moves all of its children from the global origin to the center of the area that a compartment would normally fill, and uses them to cut from the bin. This allows you to easily make custom cutouts in the bin.
Parameter | Range | Description
--- | ----- | ---
`x` | {n>=0\|n∈R} | X coordinate of the area (position of left edge)
`y` | {n>=0\|n∈R} | Y coordinate of the area (position of bottom edge)
`w` | {n>0\|n∈R} | Width of the area, in base units (1 unit = 1 `length`)
`h` | {n>0\|n∈R} | Height of the area, in base units (1 unit = 1 `length`)