CLI for replacing Gridfinity bin bases with configurable presets or a base copied from another STL.
Available on PyPI as gridfinity-rebase.
Requires Python 3.10+.
Use uv to run the CLI without installing it permanently:
uvx gridfinity-rebase bin.stl --preset magnet-holesOr install it as a command available from any directory:
uv tool install gridfinity-rebase
gridfinity-rebase bin.stl --preset magnet-holesCreate and activate a virtual environment, then install the package:
python -m venv .venv
source .venv/bin/activate
python -m pip install gridfinity-rebase
gridfinity-rebase bin.stl --preset magnet-holesTo install a local checkout, run this command from the repository root:
uv tool install .Important
I tested this CLI tool only on macOS machine.
Pass an STL file to replace its base. You can also use the explicit
gridfinity-rebase rebase subcommand. Run gridfinity-rebase without arguments
to display help.
# Create smooth bottom-loading magnet pockets in bin-rebased-magnet-holes.stl.
gridfinity-rebase bin.stl --preset magnet-holes
# Create side-loading magnet pockets in bin-rebased-rebuilt.stl.
gridfinity-rebase bin.stl --preset rebuilt
# Create screw holes without magnet pockets in bin-rebased-screws.stl.
gridfinity-rebase bin.stl --screws
# Add screw holes to bottom-loading press-fit pockets
gridfinity-rebase bin.stl --preset press-fit --screws
# Place magnet pockets and screw holes only at the four outer corners of the bin.
gridfinity-rebase bin.stl --preset rebuilt --screws --only-corners
# Add side-loading magnet pockets and an M15x1.5 thumbscrew hole.
# The output is bin-rebased-rebuilt-thumbscrew.stl.
gridfinity-rebase bin.stl --preset rebuilt --thumbscrew
# Copy a base from another bin
gridfinity-rebase bin.stl --base donor.stl -o result.stl
# Inspect a model or list presets
gridfinity-rebase inspect bin.stl
gridfinity-rebase presetsAvailable presets: plain, magnet-holes, rebuilt and press-fit.
refined is an alias for rebuilt.
magnet-holes creates smooth bottom-loading Ø6.5 × 2.4 mm pockets without ribs.
press-fit adds eight crush ribs to each pocket. You can also get this geometry
with --preset magnet-holes --crush-ribs.
The previews show the same 2×3 example bin from underneath. Click a preview for the full-size image.
Append the options in each row to gridfinity-rebase bin.stl.
The default preset is plain. Select another preset or change individual settings:
--magnets none|side|bottom: no magnet pockets, side-loading pockets, or bottom-loading pockets.--side-pocket-height MM: set the side-loading pocket height. The default is 2.1 mm.--screws/--no-screws: enable or disable 3 mm screw bores.--crush-ribs/--no-crush-ribs: enable or disable ribs in bottom-loading pockets.--only-corners: limit magnet pockets and 3 mm screw bores to the four outer corners of the whole bin, regardless of grid size. A 1×1 bin keeps all four holes. Central--thumbscrewholes still appear in every foot.--thumbscrew/--no-thumbscrew: enable or disable the central threaded hole.
Add flags to a preset to combine magnet pockets, screws and central threads, or to place magnet pockets and screw bores only at the outer corners.
The images show geometry generated by the CLI. Regenerate the graphics.
See curve resolution for --segments settings and visual comparisons.
- The CLI supports standard rectangular Gridfinity bins on a 42 mm grid. Use millimeters for STL units, with feet at the bottom and Z pointing up.
- Any rotation around Z is detected automatically, including for a separately rotated donor. Processing uses a common local frame: feet aligned with X/Y, the first foot centered at X=Y=0, and the underside at Z=0. The result returns to the input's original position and rotation. Models lying on their side or upside down are not automatically reoriented.
- The CLI detects the base and cut height. If the feet are valid Gridfinity but the full base is not recognized, it replaces only the bottom 4.75 mm foot profile and prints a warning. Geometry above the cut is preserved, including any old holes. Check these results in a slicer. Invalid meshes, incompatible seams and disconnected replacement feet still fail validation.
- A donor base can match the input grid or have its X/Y dimensions swapped. The CLI can also tile a 1×1 donor base across the input.
- Unmodified presets write to
bin-rebased-PRESET.stl.--thumbscrewand--only-cornersappend their names to the filename. Modified settings use a descriptive suffix, such asbin-rebased-magnets-bottom-crush-ribs-screws.stl. Donor bases usebin-rebased.stl. Use-oto choose a filename and--overwriteto replace an existing output. - JSON reports include the resolved
geometrysettings and awarningsarray (empty when there are no warnings). With--json, warnings are included in the report instead of printed to stderr.base_height_modeisautowhen the program chooses the cut height, ormanualwhen--base-heightis supplied. Automatic 4.75 mm foot replacement includes a warning.baseidentifies the starting preset or donor path. The default preset isplain. For donor bases,geometryisnull. - Inspection and rebase reports include
rotation_z_deg, the local grid's rotation in the source coordinates, andorigin_mm, its first foot's center at underside height in those same coordinates. Square feet determine rotation modulo 90°; the reported angle is in [-45°, 45°), so equivalent orientations can swap the reported grid's X/Y dimensions. Reported cut heights remain relative to the underside. --base-height MMoverrides automatic detection for custom models and replaces everything below that height. The minimum is 4.75 mm.
Run gridfinity-rebase --help for all options.
Run the benchmark from the repository root:
uv run --locked --python 3.11 python scripts/benchmark.py --runs 5The benchmark generates all test models locally. You do not need to download example STLs. See benchmark instructions, methodology and reference results for JSON output and environment details.
Szymon here. I used AI to build this tool.
I needed a way to quickly replace the base of custom Gridfinity bins downloaded from the Internet, but I didn't want to spend too much of my free time on this. I collaborated with the AI, describing how it should work, how I want to use it and what's the important from the both code perspective and end-user perspective. It allowed me to iterate and create something that is exactly what I needed. Now I share it with you.
Just want you to know.
The MIT license covers this CLI and its adapted preset implementation.
Processing a model does not replace its existing license or attribution requirements. When sharing a rebased STL, preserve applicable notices and comply with the licenses of the input model and any donor geometry.
Preset geometry is adapted from the MIT-licensed Gridfinity Rebuilt implementation by Kenneth Hodson, based on Gridfinity by Zack Freedman. Rebuilt credits Gridfinity Refined by grizzie17 as the source of its side-loading magnet pockets.
Rebuilt source files at revision 910e22d8607fd7f5f51ad5e5cbc5287a76810bfd:
- standard.scad: mating profile, grid, radii and hole dimensions.
- gridfinity-rebuilt-holes.scad: side-loading magnet pockets and crush ribs.
- base.scad: fan arrangement of the four pockets and the central threaded hole.
The native thumbscrew thread tessellation derives from ScrewThread() in
threads-scad,
created in 2016 — 2017 by Ryan A. Colyer and released under CC0 1.0.