cadbuildr-gridfinity 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. cadbuildr_gridfinity-0.2.0/.cadbuildr_code/skills/cadbuildr-foundation/SKILL.md +255 -0
  2. cadbuildr_gridfinity-0.2.0/.github/workflows/python.yml +34 -0
  3. cadbuildr_gridfinity-0.2.0/.gitignore +17 -0
  4. cadbuildr_gridfinity-0.2.0/CADBUILDR.md +9 -0
  5. cadbuildr_gridfinity-0.2.0/CHANGELOG.md +37 -0
  6. cadbuildr_gridfinity-0.2.0/LICENSE +21 -0
  7. cadbuildr_gridfinity-0.2.0/PKG-INFO +159 -0
  8. cadbuildr_gridfinity-0.2.0/README.md +147 -0
  9. cadbuildr_gridfinity-0.2.0/SKILL.md +64 -0
  10. cadbuildr_gridfinity-0.2.0/cadbuildr/__init__.py +3 -0
  11. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/__init__.py +87 -0
  12. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/_base.py +177 -0
  13. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/_geom.py +117 -0
  14. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/assemblies.py +108 -0
  15. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/baseplates.py +255 -0
  16. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/bins.py +333 -0
  17. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/errors.py +38 -0
  18. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/inserts.py +397 -0
  19. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/interfaces.py +47 -0
  20. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/layout.py +104 -0
  21. cadbuildr_gridfinity-0.2.0/cadbuildr/gridfinity/spec.py +383 -0
  22. cadbuildr_gridfinity-0.2.0/docs/images/baseplate-before-after.png +0 -0
  23. cadbuildr_gridfinity-0.2.0/docs/images/bin-before-after.png +0 -0
  24. cadbuildr_gridfinity-0.2.0/docs/images/organiser.png +0 -0
  25. cadbuildr_gridfinity-0.2.0/eval/iou_eval.py +193 -0
  26. cadbuildr_gridfinity-0.2.0/examples/demo_drawer.py +15 -0
  27. cadbuildr_gridfinity-0.2.0/examples/single_bin.py +9 -0
  28. cadbuildr_gridfinity-0.2.0/github-io/.gitignore +3 -0
  29. cadbuildr_gridfinity-0.2.0/github-io/README.md +46 -0
  30. cadbuildr_gridfinity-0.2.0/github-io/index.html +24 -0
  31. cadbuildr_gridfinity-0.2.0/github-io/package-lock.json +2506 -0
  32. cadbuildr_gridfinity-0.2.0/github-io/package.json +36 -0
  33. cadbuildr_gridfinity-0.2.0/github-io/pnpm-lock.yaml +1734 -0
  34. cadbuildr_gridfinity-0.2.0/github-io/public/cadbuildr-logo.svg +53 -0
  35. cadbuildr_gridfinity-0.2.0/github-io/public/local-starter/.gitkeep +0 -0
  36. cadbuildr_gridfinity-0.2.0/github-io/public/local-starter/cadbuildr_gridfinity-0.2.0-py3-none-any.whl +0 -0
  37. cadbuildr_gridfinity-0.2.0/github-io/src/kernelApiEnv.ts +10 -0
  38. cadbuildr_gridfinity-0.2.0/github-io/src/main.tsx +516 -0
  39. cadbuildr_gridfinity-0.2.0/github-io/src/starterLocal.ts +5 -0
  40. cadbuildr_gridfinity-0.2.0/github-io/src/styles.css +229 -0
  41. cadbuildr_gridfinity-0.2.0/github-io/src/vite-env.d.ts +13 -0
  42. cadbuildr_gridfinity-0.2.0/github-io/tsconfig.json +28 -0
  43. cadbuildr_gridfinity-0.2.0/github-io/vite.config.ts +50 -0
  44. cadbuildr_gridfinity-0.2.0/logo.png +0 -0
  45. cadbuildr_gridfinity-0.2.0/pyproject.toml +50 -0
  46. cadbuildr_gridfinity-0.2.0/tests/__init__.py +0 -0
  47. cadbuildr_gridfinity-0.2.0/tests/_kernel.py +56 -0
  48. cadbuildr_gridfinity-0.2.0/tests/test_geometry.py +218 -0
  49. cadbuildr_gridfinity-0.2.0/tests/test_items.py +213 -0
  50. cadbuildr_gridfinity-0.2.0/tests/test_spec.py +163 -0
@@ -0,0 +1,255 @@
1
+ ---
2
+ name: cadbuildr-foundation
3
+ description: CADbuildr foundation reference and harness rules for local CADbuildr agent sessions.
4
+ ---
5
+
6
+ # Foundation Cheatsheet
7
+
8
+ Use reliable primitives first, then compose.
9
+
10
+ - Start from `Part`/`Assembly` and explicit `Sketch` planes.
11
+ - Prefer clear, dimension-driven constants for repeatability.
12
+ - Use `Extrusion`, `Lathe`, and `Hole` as the default operation set.
13
+ - Keep transforms explicit with `translate_*`/`rotate` or `TFHelper`.
14
+ - End scripts with a direct `show(...)` call for local validation.
15
+
16
+ ## Canonical imports
17
+
18
+ ```python
19
+ from cadbuildr.foundation import (
20
+ Part,
21
+ Assembly,
22
+ Plane,
23
+ Sketch,
24
+ Point,
25
+ Line,
26
+ Axis,
27
+ Polygon,
28
+ Circle,
29
+ Ellipse,
30
+ Rectangle,
31
+ Square,
32
+ SVGShape,
33
+ Lathe,
34
+ Extrusion,
35
+ Hole,
36
+ Material,
37
+ TFHelper,
38
+ show,
39
+ )
40
+ ```
41
+
42
+ ## Parts and assemblies
43
+
44
+ ```python
45
+ Part() -> Part
46
+ Assembly() -> Assembly
47
+ Part.add_operation(operation) -> bool | None
48
+ Assembly.add_component(component, tf=None) -> bool | None
49
+ ```
50
+
51
+ ## Planes
52
+
53
+ ```python
54
+ (Part | Assembly).xy() -> Plane
55
+ (Part | Assembly).yz() -> Plane
56
+ (Part | Assembly).xz() -> Plane
57
+ Plane.get_parallel_plane(distance: float, name: str = "parallel") -> Plane | None
58
+ Plane.get_angle_plane_from_axis(axis: list[float], angle: float, name: str = "rotated") -> Plane | None
59
+ ```
60
+
61
+ ## Sketches and elements
62
+
63
+ ```python
64
+ sketch = Sketch(plane)
65
+ Point(sketch, x, y) -> Point
66
+ Line(p1, p2) -> Line
67
+ Axis(line) -> Axis
68
+ ```
69
+
70
+ ## Sketch shapes
71
+
72
+ ```python
73
+ Polygon(lines) -> Polygon
74
+ Circle(center, radius) -> Circle
75
+ Ellipse(center, a, b) -> Ellipse
76
+ Rectangle.from_center_and_sides(center, w, h) -> Rectangle | None
77
+ Rectangle.from_2_corners(p1, p2) -> Rectangle | None
78
+ Rectangle.from_2_points(p1, p2) -> Rectangle | None # legacy alias
79
+ Square.from_center_and_side(center, size) -> Square | None
80
+ ```
81
+
82
+ ## SVG import in sketches
83
+
84
+ ```python
85
+ SVGShape(
86
+ sketch,
87
+ svg,
88
+ xshift=0.0,
89
+ yshift=0.0,
90
+ angle=0.0,
91
+ scale=1.0,
92
+ ) -> CustomClosedShape
93
+ ```
94
+
95
+ - Use `SVGShape` to convert an SVG string into a sketch shape, then pass it to `Extrusion` or `Lathe`.
96
+ - Keep `viewBox` explicit in the SVG string; the viewbox center maps to the sketch origin before shifts.
97
+ - Supported SVG elements: `path`, `text`, `rect`, `circle`, `ellipse`, `line`, `polygon`.
98
+
99
+ ## Pencil API
100
+
101
+ `Sketch` exposes `sketch.pencil` for draw helpers.
102
+
103
+ ```python
104
+ sketch.pencil.move(dx, dy)
105
+ sketch.pencil.move_to(x, y)
106
+ sketch.pencil.line(dx, dy)
107
+ sketch.pencil.line_to(x, y)
108
+ sketch.pencil.arc(dx, dy, radius)
109
+ sketch.pencil.arc_to(x, y, radius)
110
+ sketch.pencil.tangent_arc(dx, dy)
111
+ sketch.pencil.tangent_arc_to(x, y)
112
+ sketch.pencil.rounded_corner_then_line(dx, dy, radius)
113
+ sketch.pencil.rounded_corner_then_line_to(x, y, radius)
114
+ sketch.pencil.get_closed_shape()
115
+ sketch.pencil.close_with_mirror()
116
+ ```
117
+
118
+ ## Operations
119
+
120
+ ```python
121
+ Lathe(shape, axis, cut=False) -> Lathe
122
+ Extrusion([shape], end, start=0, cut=False, taper=0.0, direction=None) -> Extrusion
123
+ Hole(point, radius, depth) -> Hole
124
+ ```
125
+
126
+ ## 3D primitives
127
+
128
+ ```python
129
+ Sphere(center, radius, cut=False) -> Sphere
130
+ Box(center, w, h, d, cut=False) -> Extrusion
131
+ Cylinder(center, radius, height, cut=False) -> Lathe
132
+ Cone(center, r1, r2, height) -> Lathe
133
+ Torus(center, major_radius, minor_radius) -> Lathe
134
+ Wedge(center, dx, dy, dz, ltx) -> Wedge
135
+ ```
136
+
137
+ ## 2D shapes
138
+
139
+ ```python
140
+ RegularPolygon(center, n_sides, radius) -> Polygon
141
+ RectangleRounded(center, w, h, radius) -> CustomClosedShape
142
+ Trapezoid(center, w_top, w_bottom, h) -> Polygon
143
+ Triangle(p1, p2, p3) -> Polygon
144
+ SlotCenterToCenter(p1, p2, height) -> CustomClosedShape
145
+ SlotOverall(center, width, height) -> SlotCenterToCenter
146
+ SlotCenterPoint(center, point, height) -> SlotCenterToCenter
147
+ ConvexHull(points) -> Polygon
148
+ Text(sketch, text, size, font_url) -> Text
149
+ ```
150
+
151
+ ## Hole variants
152
+
153
+ ```python
154
+ CounterBoreHole(point, radius, depth, cbore_radius, cbore_depth) -> Lathe
155
+ CounterSinkHole(point, radius, depth, csink_radius, csink_angle_deg) -> Lathe
156
+ TappedHole(point, thread_size, depth) -> Hole # bore at radius = thread_size/2
157
+ ```
158
+
159
+ ## Solid transforms
160
+
161
+ ```python
162
+ Mirror(shape, plane_name) -> Mirror # plane_name in {"XY", "YZ", "XZ"}
163
+ Scale(shape, factor) -> Scale # uniform
164
+ Offset2D(shape, distance) -> Offset2D
165
+ BoundingBox(shape) -> BoundingBox
166
+ Section(solid, plane_name) -> Section
167
+ Split(solid, plane_name, keep) -> Split
168
+ Project(shape, target_plane_name) -> Project
169
+ Draft(solid, angle_deg, neutral_plane_name, edge_finder) -> Draft
170
+ FullRound(solid, face_finder) -> FullRound
171
+ Trace(path_points, width) -> Trace
172
+ ```
173
+
174
+ ## Pattern helpers
175
+
176
+ ```python
177
+ GridLocations(center, x_pitch, y_pitch, n_x, n_y).positions() -> list[Point]
178
+ HexLocations(center, pitch, n_radial).positions() -> list[Point]
179
+ PolarLocations(center, radius, count, start_angle_deg=0, angular_range_deg=360).positions() -> list[Point]
180
+ Locations(center, [(dx, dy), ...]).positions() -> list[Point]
181
+ ```
182
+
183
+ ## 1D curves
184
+
185
+ ```python
186
+ Polyline([points]) -> CustomOpenShape
187
+ FilletPolyline([points], radius) -> CustomOpenShape
188
+ Bezier([start, ctrl1, ..., end]) -> Bezier
189
+ BSpline([points], degree=3) -> BSpline
190
+ ThreePointArc(p1, p2, p3) -> Arc
191
+ RadiusArc(p1, p3, radius) -> Arc
192
+ CenterArc(center, radius, start_angle_deg, end_angle_deg) -> Arc
193
+ SagittaArc(p1, p3, sagitta) -> Arc
194
+ TangentArc(p1, p3, tangent) -> Arc
195
+ JernArc(start, tangent, radius, arc_size_deg) -> Arc
196
+ EllipticalCenterArc(center, x_radius, y_radius, start_angle_deg, end_angle_deg) -> EllipseArc
197
+ Helix2D(center, pitch, radius_outer, n_turns) -> Spline
198
+ Spline(points, start_tangent=None, end_tangent=None) -> Spline
199
+ ```
200
+
201
+ ## Selectors
202
+
203
+ Extend `EdgeFinder.rule` with these to filter edges/faces:
204
+
205
+ ```python
206
+ IsCircleRule()
207
+ OfTypeRule(type_name) # "LINE" | "CIRCLE" | "BSPLINE" | "ELLIPSE"
208
+ LengthRangeRule(min, max)
209
+ RadiusRangeRule(min, max)
210
+ ParallelToAxisRule(axis) # "X" | "Y" | "Z"
211
+ OnFaceRule(face_finder)
212
+ SortByRule(rule, by, take="FIRST", n=1) # by: LENGTH|RADIUS|AREA|VOLUME|DISTANCE
213
+ ```
214
+
215
+ ## Transforms
216
+
217
+ ```python
218
+ (Part | Assembly).translate([x, y, z]) -> bool | None
219
+ (Part | Assembly).translate_x(x) -> bool | None
220
+ (Part | Assembly).translate_y(y) -> bool | None
221
+ (Part | Assembly).translate_z(z) -> bool | None
222
+ (Part | Assembly).rotate(angle, axis=[0.0, 0.0, 1.0]) -> bool | None
223
+ ```
224
+
225
+ ## Materials
226
+
227
+ ```python
228
+ material = Material()
229
+ material.set_diffuse_color("red") # or [r, g, b]
230
+ part.set_material(material)
231
+ part.paint("blue", transparency=0.5)
232
+ ```
233
+
234
+ ## TFHelper
235
+
236
+ ```python
237
+ tf = TFHelper()
238
+ tf.get_tf() -> dict
239
+ tf.set_tf(value)
240
+ tf.translate([x, y, z])
241
+ tf.translate_x(x)
242
+ tf.translate_y(y)
243
+ tf.translate_z(z)
244
+ tf.rotate(axis, angle)
245
+ ```
246
+
247
+ ## Good practice
248
+
249
+ - For reusable parts, define subclasses of `Part` and split build logic into methods.
250
+ - For reusable assemblies, define subclasses of `Assembly` and compose children explicitly.
251
+
252
+ ## CADbuildr harness rules (desktop)
253
+
254
+ - Use `cadbuildr.foundation` for solid CAD; end with `show(...)`.
255
+ - Do not satisfy CAD geometry requests with matplotlib, HTML, Three.js, or WebGL unless the user explicitly asked for web visualization.
@@ -0,0 +1,34 @@
1
+ name: pytest
2
+
3
+ on:
4
+ push:
5
+ branches: ["main", "initial-implementation"]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ python-version: ["3.11", "3.12"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v6
19
+ with:
20
+ enable-cache: true
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ run: uv venv --python ${{ matrix.python-version }}
23
+ # TEMPORARY: cadbuildr-foundation 0.3.0 is not on PyPI yet. Install it
24
+ # from the foundation repo until it is released, then drop this step
25
+ # (the pin in pyproject.toml, >=0.3.0,<0.4.0, resolves from PyPI).
26
+ - name: Install cadbuildr-foundation from git (temporary)
27
+ run: uv pip install "cadbuildr-foundation @ git+https://github.com/cadbuildr/foundation@master"
28
+ - name: Install package
29
+ run: uv pip install -e . pytest
30
+ # Geometry tests that mesh the real solids run when a kernel API is
31
+ # reachable (CADBUILDR_KERNEL_API_BASE_URL); here they skip and the
32
+ # analytic / operation-level geometry tests run.
33
+ - name: Test with pytest
34
+ run: uv run --no-sync pytest -q
@@ -0,0 +1,17 @@
1
+ # Python
2
+ __pycache__/
3
+ *.pyc
4
+ .venv/
5
+ .pytest_cache/
6
+ .mypy_cache/
7
+ .ruff_cache/
8
+ # Builds / artifacts
9
+ dist/
10
+ build/
11
+ *.egg-info/
12
+ # Tooling caches
13
+ .uv-cache/
14
+ # Editor / OS
15
+ .DS_Store
16
+ .idea/
17
+ .vscode/
@@ -0,0 +1,9 @@
1
+ # CADbuildr
2
+
3
+ This workspace is used with **CADbuildr agent** and the CADbuildr harness.
4
+
5
+ - Implement CAD geometry with **cadbuildr.foundation** in Python.
6
+ - End runnable scripts with **show(...)** so CADbuildr Prototype's viewer can render.
7
+ - Do **not** use matplotlib, raw HTML, Three.js, or WebGL to display CAD solids unless the user explicitly asked for a web visualization demo.
8
+
9
+ Progressive disclosure: read the Agent Skill under `.cadbuildr_code/skills/cadbuildr-foundation/` when you need API details.
@@ -0,0 +1,37 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 — unreleased
4
+
5
+ Library release: the starter-template package becomes `cadbuildr-gridfinity`
6
+ (`import cadbuildr.gridfinity`), on `cadbuildr-foundation>=0.3.0,<0.4.0`.
7
+
8
+ - **Package** `cadbuildr/gridfinity/` (replaces `starter/`) with typed
9
+ `@part` / `@assembly` library items, presets, a `cadbuildr.libraries`
10
+ entry point, named errors and `__checks__` issues.
11
+ - **Spec** (`spec.py`): every dimension cited to Zack Freedman's spec or
12
+ Gridfinity Rebuilt; profile cross-sections, seat offsets (bin on plate 0,
13
+ stacked −0.35 mm), analytic volumes, `drawer_fit`, `tile_layout`.
14
+ - **Bins**: `GridfinityBin` (any W × D × H, dividers in X / Y, scoop, GR
15
+ angled label tab none/full/left/center/right, open stacking lip with its
16
+ support, magnet / screw holes per cell or at the corners, vase mode, half
17
+ pitch), `GridfinityBlock`. The open lip, label tabs and scoops of the
18
+ `fix/open-bins-pocket-baseplate` branch are kept and now follow the GR
19
+ profiles (36° tab, lip support).
20
+ - **Baseplates**: pockets to the GR baseplate profile (0.35 mm straight +
21
+ 0.7 / 1.8 / 2.15 mm, full 42 mm at the top); styles plain / magnet /
22
+ weighted / screw-together; `GridfinityDrawerBaseplate` fits a drawer with
23
+ the padding split by `fit_x` / `fit_y`.
24
+ - **Accessories**: `GridfinityHexBitInsert` (ISO 1173 1/4 in and 4 mm),
25
+ `GridfinityHoleInsert`, `GridfinityCutoutInsert` (2D outline),
26
+ `GridfinityLid` (stackable).
27
+ - **Interfaces**: `GridfinityFoot` ↔ `GridfinitySocket` (rigid, same pitch),
28
+ `cell_<i>_<j>` / `stack_<i>_<j>` sockets; `place_bin`, `stack_on`,
29
+ `parse_layout`; assemblies `GridfinityDrawer` and `GridfinityDemoDrawer`.
30
+ - Tests (spec, items, geometry; kernel volume tests when a kernel API is
31
+ set), CI workflow (uv, Python 3.11 / 3.12), README, `SKILL.md`, LICENSE.
32
+ - `github-io/` generator moved to the new API (half grid, label, scoop,
33
+ hole placement, baseplate styles) and foundation `^0.3.0`.
34
+
35
+ ## 0.1.0
36
+
37
+ Starter-template Gridfinity generator (`starter/`) and the github-io demo.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CADbuildr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.5
2
+ Name: cadbuildr-gridfinity
3
+ Version: 0.2.0
4
+ Summary: The Gridfinity modular storage system on CADbuildr: bins, baseplates (plain/magnet/weighted/screw, fit to a drawer), hex-bit / hole / cut-out inserts and lids, placed by connect
5
+ Project-URL: Homepage, https://github.com/cadbuildr/gridfinity
6
+ Author: CADbuildr Team
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Python: <4.0.0,>=3.10.0
10
+ Requires-Dist: cadbuildr-foundation<0.4.0,>=0.3.0
11
+ Description-Content-Type: text/markdown
12
+
13
+ # cadbuildr-gridfinity
14
+
15
+ ## Summary
16
+
17
+ The [Gridfinity](https://gridfinity.xyz/specification/) modular storage
18
+ system (Zack Freedman, 2022) as a CADbuildr library
19
+ (`pip install cadbuildr-gridfinity`, `import cadbuildr.gridfinity`): parametric
20
+ bins, baseplates for any drawer, tool-holder inserts and lids, all typed
21
+ `@part` / `@assembly` library items that stand on each other through a
22
+ `GridfinityFoot` / `GridfinitySocket` interface pair and `connect`.
23
+
24
+ Dimensions follow the community reference
25
+ [Gridfinity Rebuilt](https://github.com/kennetek/gridfinity-rebuilt-openscad)
26
+ (kennetek, MIT), modelled here from its published numbers (no code copied):
27
+ 42 mm grid, 7 mm height unit, bin outer `42 n - 0.5` mm (0.25 mm clearance),
28
+ base profile 0.8 mm 45° / 1.8 mm vertical / 2.15 mm 45° (4.75 mm) plus a
29
+ 2.25 mm bridge, baseplate pocket 0.7 / 1.8 / 2.15 mm on a 0.35 mm straight,
30
+ stacking lip 0.7 / 1.8 / 1.9 mm, Ø6.5 × 2.4 mm magnet holes and Ø3 mm M3
31
+ screw holes 8 mm from the cell edges. Every number, with its source, is in
32
+ [`cadbuildr/gridfinity/spec.py`](cadbuildr/gridfinity/spec.py).
33
+
34
+ A [Vite + React-Three-Fiber generator](github-io/) renders bins and
35
+ baseplates live in the browser through the CADbuildr SDK.
36
+
37
+ ![A stocked desk organiser](docs/images/organiser.png)
38
+
39
+ ## Quickstart
40
+
41
+ ```bash
42
+ pip install cadbuildr-gridfinity # pulls cadbuildr-foundation>=0.3.0,<0.4.0
43
+ ```
44
+
45
+ ```python
46
+ from cadbuildr.foundation import Assembly, show
47
+ from cadbuildr.gridfinity import (
48
+ GridfinityBin, GridfinityDrawerBaseplate, GridfinityHexBitInsert, place_bin,
49
+ )
50
+
51
+ plate = GridfinityDrawerBaseplate(drawer_width=180, drawer_depth=130, style="magnet") # 4 x 3, 6 / 2 mm padding
52
+ drawer = Assembly()
53
+ drawer.ground(plate)
54
+ place_bin(drawer, GridfinityBin(units_x=2, units_y=2, units_z=6, dividers_x=1), plate, 0, 0)
55
+ place_bin(drawer, GridfinityHexBitInsert(), plate, 2, 0) # checked: on the plate, cells free, same pitch
56
+ assert [i for i in drawer.check() if i["severity"] == "error"] == []
57
+ show(drawer)
58
+ ```
59
+
60
+ Or the ready-made demo (a 4 × 3 drawer with a mix of bins, inserts and a
61
+ stacked lid): `python examples/demo_drawer.py`, or in
62
+ [CADbuildr Prototype](https://cadbuildr.com/downloads) open the folder and
63
+ press Play on `examples/demo_drawer.py`.
64
+
65
+ ```bash
66
+ python -m cadbuildr.foundation.library manifest cadbuildr.gridfinity
67
+ echo '{"item": "gridfinity:GridfinityBin", "inputs": {"units_x": 3, "dividers_x": 2}}' \
68
+ | python -m cadbuildr.foundation.library eval
69
+ ```
70
+
71
+ ## Catalogue
72
+
73
+ | Item | What it is | Key inputs |
74
+ |---|---|---|
75
+ | `GridfinityBin` | Open bin: a foot per cell, walls, open stacking lip, dividers, a finger scoop and an angled label tab (GR 15.85 mm / 36°) per row, magnet and screw holes, vase-mode (solid) variant, 21 mm half grid | `units_x/y/z`, `dividers_x/y`, `label` (none/full/left/center/right), `scoop`, `stacking_lip`, `magnets`, `screws`, `holes_only_corners`, `wall`, `vase_mode`, `half_pitch` |
76
+ | `GridfinityBlock` | Solid bin (riser / spacer / blank), optional lip recess on top | `units_x/y/z`, `stacking_lip`, `magnets`, `screws` |
77
+ | `GridfinityBaseplate` | Pockets to the GR baseplate profile; styles `plain` (5 mm frame), `magnet` (3.4 mm floor), `weighted` (6.4 mm floor, 21.4 mm weight pockets + ribs), `screw` (6.75 mm floor, Ø3.35 mm cross holes) | `units_x/y`, `style`, `half_pitch`, `pad_*` |
78
+ | `GridfinityDrawerBaseplate` | Fills a drawer: `floor(W/42)` × `floor(D/42)` cells, padding split by `fit_x/y` (−1 / 0 / +1) | `drawer_width`, `drawer_depth`, `style`, `fit_x/y` |
79
+ | `GridfinityHexBitInsert` | Grid of hex sockets for ISO 1173 bits (1/4 in = 6.35 mm, or 4 mm) | `bit`, `depth`, `clearance`, `columns`, `rows` |
80
+ | `GridfinityHoleInsert` | Round holes of any diameters, packed in rows | `diameters` ("6, 8, 10"), `depth`, `clearance` |
81
+ | `GridfinityCutoutInsert` | Shadow-board pocket from a 2D outline | `outline` ("x,y; x,y; ..."), `depth` |
82
+ | `GridfinityLid` | Feet that seat in a bin's lip under a plate; `stackable` adds a baseplate frame on top | `units_x/y`, `stackable` |
83
+ | `GridfinityDrawer` | Drawer baseplate + items from a layout string (`"bin 2x2x6@0,0; hexbit 1x1x3@2,0"`) | `drawer_width/depth`, `style`, `layout` |
84
+ | `GridfinityDemoDrawer` | The 4 × 3 demo drawer | `style` |
85
+
86
+ Helpers: `place_bin`, `stack_on`, `parse_layout`, `tile_layout` (split a big
87
+ plate into printable tiles), `drawer_fit`, and `spec` (dimensions, profile
88
+ cross-sections, seat offsets, analytic volumes). `GridfinityBox` is an alias
89
+ of `GridfinityBin` (the cq-gridfinity name).
90
+
91
+ Interfaces: `GridfinitySocket` (female, +Z up) at every pocket floor
92
+ (`cell_<i>_<j>`, `i` along +X, `j` along +Y from the corner cell), on top of
93
+ every bin with a lip (`stack_<i>_<j>`, 0.35 mm below the body top where a
94
+ stacked base comes to rest) and on stackable lids; `GridfinityFoot` (male,
95
+ +Z down) under every bin's first cell (`foot`). The mate rule is rigid and
96
+ requires the same pitch.
97
+
98
+ ## Tags
99
+
100
+ cad, python, library, gridfinity, storage, organizer, 3d-printing, parametric, open-source
101
+
102
+ ## Status
103
+
104
+ yellow
105
+
106
+ ## Guidelines
107
+
108
+ - Every dimension comes from `spec.py`, which cites Zack Freedman's spec or
109
+ Gridfinity Rebuilt per constant; values the sources do not give are
110
+ listed under *Estimated* there and in the docstrings. Model from the
111
+ published numbers; never copy the reference's code.
112
+ - Bins stand on plates by `connect` (`place_bin` / `stack_on`), never by
113
+ coordinates.
114
+ - Bad inputs raise a named `GridfinityError` subclass (`GridSizeError`,
115
+ `OptionConflictError`, `FitError`, `OutlineError`, `LayoutError`), never a
116
+ silent clamp. Findings that are not errors (thin walls, oversize plates)
117
+ are issues from a `__checks__` hook; never override `check()`.
118
+ - Geometry tests check boxes, profiles and analytic volumes without a
119
+ kernel; with `CADBUILDR_KERNEL_API_BASE_URL` set they also mesh the real
120
+ solids and compare volumes.
121
+ - Keep `github-io/` working when the API moves (`buildPythonSource` in
122
+ `github-io/src/main.tsx`), and rebuild the wheel it serves
123
+ (`pnpm run sync-starter-wheel`).
124
+
125
+ ## Dependencies
126
+
127
+ ### Upstream
128
+
129
+ - `cadbuildr-foundation>=0.3.0,<0.4.0` (parts, library registry,
130
+ interfaces and `connect`, `__checks__`)
131
+
132
+ ### Downstream
133
+
134
+ - The [Gridfinity Generator](github-io/) site (Pyodide wheel in
135
+ `github-io/public/local-starter/`)
136
+ - CADbuildr cloud / Prototype library catalogue (entry point
137
+ `cadbuildr.libraries: gridfinity`)
138
+
139
+ ## Develop
140
+
141
+ ```bash
142
+ uv venv && uv pip install -e . pytest
143
+ uv run pytest -q # analytic + operation-level geometry
144
+ CADBUILDR_KERNEL_API_BASE_URL=http://localhost:8087 uv run pytest -q # + real solids
145
+ ```
146
+
147
+ `eval/iou_eval.py` compares the base against an OpenSCAD render of Gridfinity
148
+ Rebuilt (needs OpenSCAD and a checkout of the reference).
149
+
150
+ ## Deploy the GitHub Pages generator (optional)
151
+
152
+ The site uses the [CADbuildr SDK browser flow](https://docs.cadbuildr.com/sdk/auth)
153
+ — a short-lived session token is minted client-side using only the
154
+ **publishable half** of a partner key. See [`github-io/README.md`](github-io/README.md).
155
+
156
+ ## License
157
+
158
+ MIT (see `LICENSE`). Gridfinity is Zack Freedman's open design; Gridfinity
159
+ Rebuilt is © kennetek, MIT.
@@ -0,0 +1,147 @@
1
+ # cadbuildr-gridfinity
2
+
3
+ ## Summary
4
+
5
+ The [Gridfinity](https://gridfinity.xyz/specification/) modular storage
6
+ system (Zack Freedman, 2022) as a CADbuildr library
7
+ (`pip install cadbuildr-gridfinity`, `import cadbuildr.gridfinity`): parametric
8
+ bins, baseplates for any drawer, tool-holder inserts and lids, all typed
9
+ `@part` / `@assembly` library items that stand on each other through a
10
+ `GridfinityFoot` / `GridfinitySocket` interface pair and `connect`.
11
+
12
+ Dimensions follow the community reference
13
+ [Gridfinity Rebuilt](https://github.com/kennetek/gridfinity-rebuilt-openscad)
14
+ (kennetek, MIT), modelled here from its published numbers (no code copied):
15
+ 42 mm grid, 7 mm height unit, bin outer `42 n - 0.5` mm (0.25 mm clearance),
16
+ base profile 0.8 mm 45° / 1.8 mm vertical / 2.15 mm 45° (4.75 mm) plus a
17
+ 2.25 mm bridge, baseplate pocket 0.7 / 1.8 / 2.15 mm on a 0.35 mm straight,
18
+ stacking lip 0.7 / 1.8 / 1.9 mm, Ø6.5 × 2.4 mm magnet holes and Ø3 mm M3
19
+ screw holes 8 mm from the cell edges. Every number, with its source, is in
20
+ [`cadbuildr/gridfinity/spec.py`](cadbuildr/gridfinity/spec.py).
21
+
22
+ A [Vite + React-Three-Fiber generator](github-io/) renders bins and
23
+ baseplates live in the browser through the CADbuildr SDK.
24
+
25
+ ![A stocked desk organiser](docs/images/organiser.png)
26
+
27
+ ## Quickstart
28
+
29
+ ```bash
30
+ pip install cadbuildr-gridfinity # pulls cadbuildr-foundation>=0.3.0,<0.4.0
31
+ ```
32
+
33
+ ```python
34
+ from cadbuildr.foundation import Assembly, show
35
+ from cadbuildr.gridfinity import (
36
+ GridfinityBin, GridfinityDrawerBaseplate, GridfinityHexBitInsert, place_bin,
37
+ )
38
+
39
+ plate = GridfinityDrawerBaseplate(drawer_width=180, drawer_depth=130, style="magnet") # 4 x 3, 6 / 2 mm padding
40
+ drawer = Assembly()
41
+ drawer.ground(plate)
42
+ place_bin(drawer, GridfinityBin(units_x=2, units_y=2, units_z=6, dividers_x=1), plate, 0, 0)
43
+ place_bin(drawer, GridfinityHexBitInsert(), plate, 2, 0) # checked: on the plate, cells free, same pitch
44
+ assert [i for i in drawer.check() if i["severity"] == "error"] == []
45
+ show(drawer)
46
+ ```
47
+
48
+ Or the ready-made demo (a 4 × 3 drawer with a mix of bins, inserts and a
49
+ stacked lid): `python examples/demo_drawer.py`, or in
50
+ [CADbuildr Prototype](https://cadbuildr.com/downloads) open the folder and
51
+ press Play on `examples/demo_drawer.py`.
52
+
53
+ ```bash
54
+ python -m cadbuildr.foundation.library manifest cadbuildr.gridfinity
55
+ echo '{"item": "gridfinity:GridfinityBin", "inputs": {"units_x": 3, "dividers_x": 2}}' \
56
+ | python -m cadbuildr.foundation.library eval
57
+ ```
58
+
59
+ ## Catalogue
60
+
61
+ | Item | What it is | Key inputs |
62
+ |---|---|---|
63
+ | `GridfinityBin` | Open bin: a foot per cell, walls, open stacking lip, dividers, a finger scoop and an angled label tab (GR 15.85 mm / 36°) per row, magnet and screw holes, vase-mode (solid) variant, 21 mm half grid | `units_x/y/z`, `dividers_x/y`, `label` (none/full/left/center/right), `scoop`, `stacking_lip`, `magnets`, `screws`, `holes_only_corners`, `wall`, `vase_mode`, `half_pitch` |
64
+ | `GridfinityBlock` | Solid bin (riser / spacer / blank), optional lip recess on top | `units_x/y/z`, `stacking_lip`, `magnets`, `screws` |
65
+ | `GridfinityBaseplate` | Pockets to the GR baseplate profile; styles `plain` (5 mm frame), `magnet` (3.4 mm floor), `weighted` (6.4 mm floor, 21.4 mm weight pockets + ribs), `screw` (6.75 mm floor, Ø3.35 mm cross holes) | `units_x/y`, `style`, `half_pitch`, `pad_*` |
66
+ | `GridfinityDrawerBaseplate` | Fills a drawer: `floor(W/42)` × `floor(D/42)` cells, padding split by `fit_x/y` (−1 / 0 / +1) | `drawer_width`, `drawer_depth`, `style`, `fit_x/y` |
67
+ | `GridfinityHexBitInsert` | Grid of hex sockets for ISO 1173 bits (1/4 in = 6.35 mm, or 4 mm) | `bit`, `depth`, `clearance`, `columns`, `rows` |
68
+ | `GridfinityHoleInsert` | Round holes of any diameters, packed in rows | `diameters` ("6, 8, 10"), `depth`, `clearance` |
69
+ | `GridfinityCutoutInsert` | Shadow-board pocket from a 2D outline | `outline` ("x,y; x,y; ..."), `depth` |
70
+ | `GridfinityLid` | Feet that seat in a bin's lip under a plate; `stackable` adds a baseplate frame on top | `units_x/y`, `stackable` |
71
+ | `GridfinityDrawer` | Drawer baseplate + items from a layout string (`"bin 2x2x6@0,0; hexbit 1x1x3@2,0"`) | `drawer_width/depth`, `style`, `layout` |
72
+ | `GridfinityDemoDrawer` | The 4 × 3 demo drawer | `style` |
73
+
74
+ Helpers: `place_bin`, `stack_on`, `parse_layout`, `tile_layout` (split a big
75
+ plate into printable tiles), `drawer_fit`, and `spec` (dimensions, profile
76
+ cross-sections, seat offsets, analytic volumes). `GridfinityBox` is an alias
77
+ of `GridfinityBin` (the cq-gridfinity name).
78
+
79
+ Interfaces: `GridfinitySocket` (female, +Z up) at every pocket floor
80
+ (`cell_<i>_<j>`, `i` along +X, `j` along +Y from the corner cell), on top of
81
+ every bin with a lip (`stack_<i>_<j>`, 0.35 mm below the body top where a
82
+ stacked base comes to rest) and on stackable lids; `GridfinityFoot` (male,
83
+ +Z down) under every bin's first cell (`foot`). The mate rule is rigid and
84
+ requires the same pitch.
85
+
86
+ ## Tags
87
+
88
+ cad, python, library, gridfinity, storage, organizer, 3d-printing, parametric, open-source
89
+
90
+ ## Status
91
+
92
+ yellow
93
+
94
+ ## Guidelines
95
+
96
+ - Every dimension comes from `spec.py`, which cites Zack Freedman's spec or
97
+ Gridfinity Rebuilt per constant; values the sources do not give are
98
+ listed under *Estimated* there and in the docstrings. Model from the
99
+ published numbers; never copy the reference's code.
100
+ - Bins stand on plates by `connect` (`place_bin` / `stack_on`), never by
101
+ coordinates.
102
+ - Bad inputs raise a named `GridfinityError` subclass (`GridSizeError`,
103
+ `OptionConflictError`, `FitError`, `OutlineError`, `LayoutError`), never a
104
+ silent clamp. Findings that are not errors (thin walls, oversize plates)
105
+ are issues from a `__checks__` hook; never override `check()`.
106
+ - Geometry tests check boxes, profiles and analytic volumes without a
107
+ kernel; with `CADBUILDR_KERNEL_API_BASE_URL` set they also mesh the real
108
+ solids and compare volumes.
109
+ - Keep `github-io/` working when the API moves (`buildPythonSource` in
110
+ `github-io/src/main.tsx`), and rebuild the wheel it serves
111
+ (`pnpm run sync-starter-wheel`).
112
+
113
+ ## Dependencies
114
+
115
+ ### Upstream
116
+
117
+ - `cadbuildr-foundation>=0.3.0,<0.4.0` (parts, library registry,
118
+ interfaces and `connect`, `__checks__`)
119
+
120
+ ### Downstream
121
+
122
+ - The [Gridfinity Generator](github-io/) site (Pyodide wheel in
123
+ `github-io/public/local-starter/`)
124
+ - CADbuildr cloud / Prototype library catalogue (entry point
125
+ `cadbuildr.libraries: gridfinity`)
126
+
127
+ ## Develop
128
+
129
+ ```bash
130
+ uv venv && uv pip install -e . pytest
131
+ uv run pytest -q # analytic + operation-level geometry
132
+ CADBUILDR_KERNEL_API_BASE_URL=http://localhost:8087 uv run pytest -q # + real solids
133
+ ```
134
+
135
+ `eval/iou_eval.py` compares the base against an OpenSCAD render of Gridfinity
136
+ Rebuilt (needs OpenSCAD and a checkout of the reference).
137
+
138
+ ## Deploy the GitHub Pages generator (optional)
139
+
140
+ The site uses the [CADbuildr SDK browser flow](https://docs.cadbuildr.com/sdk/auth)
141
+ — a short-lived session token is minted client-side using only the
142
+ **publishable half** of a partner key. See [`github-io/README.md`](github-io/README.md).
143
+
144
+ ## License
145
+
146
+ MIT (see `LICENSE`). Gridfinity is Zack Freedman's open design; Gridfinity
147
+ Rebuilt is © kennetek, MIT.