Skip to content

Commit 26c740e

Browse files
authored
Add Support for boxes from Tailor Glad's GF Hardware System (#30)
See https://www.printables.com/model/1152814-gridfinity-hardware-storage-system-beta
1 parent 78c89ce commit 26c740e

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ gflabel predbox -w 5 "HEX\n{head(hex)} {bolt(5)}{3|}{<}M2\nM3\nM4\nM5{2|2}{<}M6\
115115

116116
![](https://github.com/ndevenish/gflabel/raw/refs/heads/readme_images/example_hex.png)
117117

118+
This is an example of a Tailor Box label using multiple columns, rows, and symbols.
119+
120+
```
121+
gflabel tailorbox -w=5 "M3 {|} Bolts Nuts\nWashers\n{hexhead(hex)} {hexhead(torx)} {nut} {washer}"
122+
```
123+
124+
![](https://github.com/ndevenish/gflabel/raw/refs/heads/readme_images/example_tailor.png)
125+
118126
## Command Parameters
119127

120128
The full command parameter usage (as generate by `gflabel --help`):
@@ -200,13 +208,15 @@ The base (specified by `--base=TYPE`) defines the shape of what the label is gen
200208
| ---- | ----------- | ----- |
201209
| `pred` | For [Pred's parametric labelled bins][predlabel] labels. If specifying this style, then height is ignored and width is in gridfinity units (e.g. `--width=1` for a label for a single 42mm bin). | ![](https://github.com/ndevenish/gflabel/raw/refs/heads/readme_images/base_pred.png) |
202210
| `predbox` | For labels matching the style of [Pred's Parametric Storage Box][predbox]. These are larger (~25 mm) labels for slotting in the front of the parametric storage boxes. `--width` is for the storage bin width, and is 4, 5, 6, or 7 u. | ![](https://github.com/ndevenish/gflabel/raw/refs/heads/readme_images/base_predbox.png)
211+
| `tailorbox ` | For labels matching the style of [Tailor Glad's Storage Box][tailorbox]. These are even larger labels for slotting in the front of the storage boxes. `--width` is for the storage bin width, and currently only accepts 5u. | ![](https://github.com/hartd92/gflabel/raw/refs/heads/readme_images/base_tailor.png)
203212
| `plain` | For a blank, square label with a chamfered top edge. The specified width and height will be the whole area of the label base. You must specify at least a width. | ![](https://github.com/ndevenish/gflabel/raw/refs/heads/readme_images/base_plain.png)
204213
| `cullenect` | For [Cullen J Webb's ](https://makerworld.com/en/models/446624) swappable label system. Label is a 36.4 mm x 11 mm rounded rectangle with snap-fit inserts on the back. Use without margins to match the author's style labels. | ![](https://github.com/ndevenish/gflabel/raw/refs/heads/readme_images/base_cullenect.png)
205214
| `modern` | For [Modern Gridfinity Case][modern] labels, ~22 mm high labels that slot into the front. `--width` is for the storage bin width, and can be 3, 4, 5, 6, 7 or 8 u. | ![](https://github.com/ndevenish/gflabel/raw/refs/heads/readme_images/base_modern.png) |
206215
| `none` | For no base at all - the label will still be extruded. This is useful if you want to generate a label model to place onto another volume in the slicer. | ![](https://github.com/ndevenish/gflabel/raw/refs/heads/readme_images/base_none.png) |
207216

208217
[predlabel]: https://www.printables.com/model/592545-gridfinity-bin-with-printable-label-by-pred-parame
209218
[predbox]: https://www.printables.com/model/543553-gridfinity-storage-box-by-pred-now-parametric
219+
[tailorbox]: https://www.printables.com/model/1152814-gridfinity-hardware-storage-system-beta
210220
[modern]: https://www.printables.com/model/894202-modern-gridfinity-case
211221

212222
### Label Styles

src/gflabel/bases/tailor.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from __future__ import annotations
2+
3+
import argparse
4+
import logging
5+
import sys
6+
7+
import pint
8+
from build123d import (
9+
BuildPart,
10+
BuildSketch,
11+
Plane,
12+
RectangleRounded,
13+
Vector,
14+
chamfer,
15+
extrude,
16+
)
17+
18+
from ..util import unit_registry
19+
from . import LabelBase
20+
21+
logger = logging.getLogger(__name__)
22+
23+
24+
class TailorBoxBase(LabelBase):
25+
DEFAULT_WIDTH = pint.Quantity("5u")
26+
DEFAULT_WIDTH_UNIT = unit_registry.u
27+
DEFAULT_MARGIN = unit_registry.Quantity(3, "mm")
28+
29+
def __init__(self, args: argparse.Namespace):
30+
def _convert_u_to_mm(u: pint.Quantity):
31+
if args.width.magnitude not in {5}:
32+
logger.error("Tailor box only known for 5u boxes")
33+
sys.exit(1)
34+
return pint.Quantity(
35+
{
36+
5: 96.75,
37+
}[u.magnitude],
38+
"mm",
39+
)
40+
41+
with unit_registry.context("u", fn=_convert_u_to_mm):
42+
width_mm = args.width.to("mm").magnitude
43+
44+
r_edge = 3.5
45+
depth = 1.25
46+
chamfer_d = 0.2
47+
height_mm = 24.8
48+
if args.height is not None:
49+
height_mm = args.height.to("mm").magnitude
50+
51+
with BuildPart() as part:
52+
with BuildSketch() as sketch:
53+
RectangleRounded(width_mm, height_mm, r_edge)
54+
extrude(sketch.sketch, -depth)
55+
56+
chamfer(part.faces().filter_by(Plane.XY).edges(), chamfer_d)
57+
58+
self.part = part.part
59+
self.area = Vector(width_mm - chamfer_d * 2, height_mm - chamfer_d * 2)

src/gflabel/cli.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from .bases.none import NoneBase
4545
from .bases.plain import PlainBase
4646
from .bases.pred import PredBase, PredBoxBase
47+
from .bases.tailor import TailorBoxBase
4748
from .label import render_divided_label
4849
from .options import LabelStyle, RenderOptions
4950
from .util import IndentingRichHandler, batched, unit_registry
@@ -112,7 +113,15 @@ def __call__(self, parser, namespace, values, _option_string=None):
112113
if values in deprecated_choices:
113114
values = deprecated_choices[values]
114115

115-
choices = ["pred", "plain", "none", "cullenect", "predbox", "modern"]
116+
choices = [
117+
"pred",
118+
"plain",
119+
"none",
120+
"cullenect",
121+
"predbox",
122+
"tailorbox",
123+
"modern",
124+
]
116125

117126
if values not in choices:
118127
# Allow prefix-only of choice name, as long as unambiguous
@@ -143,6 +152,7 @@ def base_name_to_subclass(name: str) -> type[LabelBase]:
143152
"modern": ModernBase,
144153
"pred": PredBase,
145154
"predbox": PredBoxBase,
155+
"tailorbox": TailorBoxBase,
146156
"plain": PlainBase,
147157
"none": NoneBase,
148158
None: NoneBase,
@@ -165,7 +175,7 @@ def run(argv: list[str] | None = None):
165175
parser.add_argument(
166176
"base",
167177
metavar="BASE",
168-
help="Label base to generate onto (pred, plain, none, cullenect, predbox, modern).",
178+
help="Label base to generate onto (pred, plain, none, cullenect, predbox, tailorbox, modern).",
169179
action=BaseChoiceAction,
170180
)
171181
parser.add_argument(

0 commit comments

Comments
 (0)