Skip to content
Willem Romijn edited this page Feb 15, 2026 · 21 revisions

1. Installation

Before using this library, ensure you have OpenSCAD installed. The Development Snapshots are significantly faster, but not required. Also, consider selecting the Manifold backend for faster rendering. Then, download the library files from the GitHub repository.

To use the library in OpenSCAD, include it in your script:

use <openscad-gridfinity-block/gridfinity_block.scad>

(Optional) Define a high-resolution rendering:

$fn = 128; // Higher values result in smoother curves

2. Creating a Basic Gridfinity Block

To generate a basic Gridfinity-compatible bin, use the gridfinity_block() function:

gridfinity_block(size = [width, depth, height], stacking_lip = false, magnets = true, center = false);

Parameters:

  • size [width, depth, height] → Defines the size of the bin in Gridfinity units:
    • width = Number of 42mm-wide units.
    • depth = Number of 42mm-deep units.
    • height = Number of “U” units in height (7mm each).
  • stacking_lip → Adds a lip for secure stacking.
  • magnets → Add holes to the bottom to fit 6x2mm magnets.
  • center → Determines the position of the OpenSCAD origin ([0,0,0]):
    • false → Origin is at the bottom-left corner of the top surface inside the walls.
    • true → Origin is at the center of the top surface.

Note: "center" is not so much about the position of the block as it is about selecting the coordinate system for your project. Choose wisely!

Example:

gridfinity_block([2, 3, 6], stacking_lip = true);

This creates a 2x3 bin, 6U high, with a stacking lip. The origin is at the bottom-left corner of the top surface inside the walls.

gridfinity_block([2, 3, 6], stacking_lip = true, center = true);

This creates the same bin, but the origin is centered on the top surface.

3. Adding Internal Features

Once the block is created, you can carve out internal features using built-in functions.

3.1 Nesting

Anything you nest inside the block gets automatically subtracted. This cuts the shape of the sphere out of the block:

gridfinity_block([1, 1, 6], stacking_lip = true, center = true) {
    sphere(20);
}

There are 3 variables available inside the nested block (but not outside of it!):

Variable Value
$inner_width The available width (x-axis distance) from wall to wall inside the block
$inner_height The available length (y-axis distance) from wall to wall inside the block
$inner_height The available height (z-axis distance) from the top of the floor to the top of the block

3.2 Creating Square Holes

For your convenience, there is a module to create a rectangular cutout within the bin:

gb_square_hole(position = [x, y], size = [width, length], depth, center = false, radius=0.8);

Parameters:

  • position [x, y] → coordinates
  • size [width, length] → dimensions of the cut
  • depth → Vertical depth of the cut.
  • center → whether the position is the bottom-left point or the center of the cut
  • radius → the radius of the rounded corners. The default of 0.8 is just right to fit inside the corners of the block.

Example:

gridfinity_block([2, 1, 6], stacking_lip = true) {
    gb_square_hole([0, 0], [$inner_width, $inner_height], depth = 15);
}

Creates a square hole over the full size of the cube, cutting 15mm deep.

3.3 Creating Round Holes

For circular cutouts, use:

gb_round_hole(position = [x, y], diameter, depth);

Parameters:

  • position [x, y] → center of the hole.
  • diameter → Width of the hole.
  • depth → Vertical depth.

Example:

gridfinity_block([1, 1, 6], stacking_lip = true) {
    gb_round_hole([15, 15], 10, depth = 10);
}

Creates a 10mm diameter hole at (15,15), 10mm deep.

4. Advanced shapes

You can also nest shapes inside a gb_square_hole or gb_round_hole. These will be subtracted from the hole. Because the hole itself is subtracted from the block, the shapes that are nested in a hole will be added to the block.

This snippet from the "Bin with scoop and label" example shows how this works:

gridfinity_block([ width, length, height ], stacking_lip = stacking_lip, center = false) {
    gb_square_hole( [0, 0], [$inner_width, $inner_length], $inner_height) {
        scoop($inner_width, scoop_radius);
        label($inner_width, $inner_length, $inner_height);
    }
}

The scoop and label modules are subtracted from the gb_square_hole, which results in them being added to the final shape.

Coordinate system inside a hole

  • Inside a gb_round_hole, the [0,0,0] point is at the center of the floor of the hole.
  • Inside a gb_square_hole, the [0,0,0] point is at the bottom left (lowest x and y coordinate) corner of the floor of the hole.

Variables

The 3 variables that are available inside the block are also available inside the holes, but with values relative to the hole:

Variable Value
$inner_width The available width (x-axis distance) from wall to wall inside the hole (diameter in case of a round hole)
$inner_height The available length (y-axis distance) from wall to wall inside the hole (diameter in case of a round hole)
$inner_height The available height (z-axis distance) from the top of the floor to the top of the hole

5. Examples

Image Example Description
Bathroom drawer bin This is what I created the library for. Multiple round cutouts for storing bottles in a bathroom cabinet drawer.
Tray for a fountain pen Demo for a simple custom bin.
Bin with scoop and label There are dozens of better libraries for this, but I wanted to see if I could make a standard bin from the block.