A python library to make Gridfinity compatible objects with CadQuery.
Project description
microfinity
A Python library to make Gridfinity compatible objects with CadQuery.
The Gridfinity system was created by Zach Freedman as a versatile system of modular organization and storage modules. This library provides Python classes to create parameterized Gridfinity components including boxes, baseplates, drawer spacers, and rugged storage boxes.
Note: This is a fork of cq-gridfinity by Michael Gale.
Installation
pip install microfinity
Or install from source:
git clone https://github.com/nullstack65/microfinity.git
cd microfinity
pip install -e .
Dependencies
Quick Start
import microfinity
print(microfinity.__version__)
from microfinity import *
# Make a simple box
box = GridfinityBox(3, 2, 5, holes=True, scoops=True, labels=True)
box.save_stl_file()
# Output: gf_box_3x2x5_holes_scoops_labels.stl
CLI Commands
microfinity-box
microfinity-box 2 3 5 -m -f stl
microfinity-base
microfinity-base 7 4 -s -f stl
microfinity-rugged
microfinity-rugged 5 4 6 --box --lid -f stl
Classes
Geometry Classes
GridfinityBox- Boxes with dividers, scoops, labels, magnet holesGridfinitySolidBox- Solid boxes without interior cutoutGridfinityBaseplate- Baseplates with optional mounting tabs and notchesGridfinityBaseplateLayout- Tiled baseplate layouts with automatic partitioning for large printsGridfinityConnectionClip- Connection clips for joining baseplate piecesGridfinityDrawerSpacer- Spacers for fitting baseplates in drawersGridfinityRuggedBox- Rugged storage boxes with lids and handles
Utility Classes
GridfinityExporter- Export utility for STEP, STL, SVG formatsSVGView- Enum for SVG view directions
Enums
EdgeMode- Edge treatment options for baseplate layoutsSegmentationMode- Partitioning strategies for large baseplatesToleranceMode- Tolerance handling for baseplate fitting
Export
The GridfinityExporter class provides a unified interface for exporting Gridfinity objects to various file formats.
Basic Usage
from microfinity import GridfinityBox, GridfinityExporter, SVGView
# Create a box
box = GridfinityBox(2, 2, 4, holes=True)
# Export using the exporter
exporter = GridfinityExporter(box)
exporter.save_step_file("box.step")
exporter.save_stl_file("box.stl")
exporter.save_svg_file("box.svg", view=SVGView.ISOMETRIC)
Direct Class Methods (Backward Compatible)
All geometry classes also have export methods directly available:
box = GridfinityBox(2, 2, 4)
box.save_stl_file() # Auto-generates filename based on parameters
box.save_step_file("custom_name.step")
box.save_svg_file("preview.svg")
SVG Views
The SVGView enum provides the following view options:
| View | Description |
|---|---|
SVGView.FRONT |
Front view (+Y direction) |
SVGView.BACK |
Back view (-Y direction) |
SVGView.LEFT |
Left view (-X direction) |
SVGView.RIGHT |
Right view (+X direction) |
SVGView.TOP |
Top view (+Z direction) |
SVGView.BOTTOM |
Bottom view (-Z direction) |
SVGView.ISOMETRIC |
Isometric view (default) |
Export Options
exporter = GridfinityExporter(obj)
# STL with custom tolerance
exporter.save_stl_file("output.stl", tolerance=0.01, angular_tolerance=0.1)
# SVG with custom styling
exporter.save_svg_file(
"output.svg",
view=SVGView.TOP,
line_width=0.5,
show_hidden=False
)
Baseplate Layout Export
GridfinityBaseplateLayout has additional export methods for batch exporting all pieces:
from microfinity import GridfinityBaseplateLayout
layout = GridfinityBaseplateLayout(
length_mm=300,
width_mm=200,
max_piece_u=4
)
# Export all pieces and clips
results = layout.export_all(
output_dir="./output",
formats=["stl", "step"],
prefix="my_baseplate"
)
# Export preview SVGs only
layout.export_preview(output_dir="./previews")
Development
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=microfinity
# Run specific test file
pytest tests/test_box.py
# Update golden test baselines
UPDATE_GOLDEN=1 pytest tests/test_golden.py
References
- Gridfinity wiki
- Original cq-gridfinity by Michael Gale
License
MIT License. Originally created by Michael Gale.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file microfinity-0.2.0.tar.gz.
File metadata
- Download URL: microfinity-0.2.0.tar.gz
- Upload date:
- Size: 87.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f43948d24f4374738d2aaf4d41e320ba943b6a792d7b0e4c811ad9fc60d87bf
|
|
| MD5 |
f090468d698c54925bdcf2baa0f38e5d
|
|
| BLAKE2b-256 |
d593afdc244fe520c7cdbebe37773b69cc0b2d015bcc8d8186ef9cee6553438d
|
Provenance
The following attestation bundles were made for microfinity-0.2.0.tar.gz:
Publisher:
release-please.yml on nullStack65/microfinity
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
microfinity-0.2.0.tar.gz -
Subject digest:
5f43948d24f4374738d2aaf4d41e320ba943b6a792d7b0e4c811ad9fc60d87bf - Sigstore transparency entry: 788728872
- Sigstore integration time:
-
Permalink:
nullStack65/microfinity@11d073dd9cc0bf8a2f75d7cf7414359e8cbf03c9 -
Branch / Tag:
refs/heads/releases - Owner: https://github.com/nullStack65
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@11d073dd9cc0bf8a2f75d7cf7414359e8cbf03c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file microfinity-0.2.0-py3-none-any.whl.
File metadata
- Download URL: microfinity-0.2.0-py3-none-any.whl
- Upload date:
- Size: 80.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a93896a56b030860a04844a12dbf2a2fe2c6fa3d93833691838ee7efc735c9e6
|
|
| MD5 |
f78c1ff41da724b08b96e09892e9159b
|
|
| BLAKE2b-256 |
2fc818e407af409ee188310694b0f9582fdc205631dd2929e2047e913e1d92c8
|
Provenance
The following attestation bundles were made for microfinity-0.2.0-py3-none-any.whl:
Publisher:
release-please.yml on nullStack65/microfinity
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
microfinity-0.2.0-py3-none-any.whl -
Subject digest:
a93896a56b030860a04844a12dbf2a2fe2c6fa3d93833691838ee7efc735c9e6 - Sigstore transparency entry: 788728877
- Sigstore integration time:
-
Permalink:
nullStack65/microfinity@11d073dd9cc0bf8a2f75d7cf7414359e8cbf03c9 -
Branch / Tag:
refs/heads/releases - Owner: https://github.com/nullStack65
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@11d073dd9cc0bf8a2f75d7cf7414359e8cbf03c9 -
Trigger Event:
push
-
Statement type: