Gflabel
Generate 3d-printable labels for gridfinity label systems
Install / Use
/learn @ndevenish/GflabelREADME
GFLabel
Generates 3d printable labels for labelled gridfinity bins (such as pred, Cullen J Webb and [Modern Gridfinity Case][modern] labels), and similar generate-smallish-printable-label uses. Leverages build123d.
State
This is a hobby project. Thus:
- Updates and attention to this project can come intermittently (although I will try to respond to outright bugs).
- It has a lot of rough edges, not the least that the output is messy and snot very useful. And functionality not used much might not work well.
- It sometimes needs manual encouragement to make labels looking good or consistent.
- A habit of sometimes crashing OCP when geometry is a little bit odd.
Usage
Installation
You should be able to install into your favorite python-virtual-environment manager by just using pip:
pip install gflabel
This should work on most modern platforms, but with the following caveats:
- Linux wheels for the dependency cadquery-ocp are only available on resonably modern (e.g. Ubuntu 22.4+) linux distributions, so you may have to go to conda to install on an older machine.
Otherwise, you can check out this repository and pip install it directly, or
install directly from the github repo:
pip install git+https://github.com/ndevenish/gflabel.git
VSCode Preview
If you are using VSCode with the vscode-ocp-cad-viewer extension,
you can add the --vscode flag when running gflabel, and the label should
show up as a preview. This saves opening the output CAD files in a slicer or
other viewer, and is useful when prototyping labels.
Basic Examples
By default, labels are written to an output file "label.step". You can change
this with -o FILENAME. .step, .stl and .svg are recognised
A simple, single label generation on a pred-style base:
gflabel pred "Basic Label" -o basic.step

Symbols are specified with { curly braces }. If you specify more labels
than divisions (which defaults to one), then multiple labels will be generated
with a single call:
gflabel pred "{nut}M2" "{nut}M3" "{nut}M4"

Or, if you specify divisions, then you can generate a multi-bin label (in this example, a margin is also added to ensure that the labels are not too dense):
gflabel pred --width 2 --divisions=3 "{nut}M2" "{nut}M3" "{nut}M4" --vscode --margin=2

You can span multiple lines, mix text and symbols, and some symbols can be passed configuration (e.g. in this case the bolt length is dynamically specified as 20mm):
gflabel pred "{head(hex)} {bolt(20)}\nM2×20"

Some symbols can also take many modifiers for e.g. drive or head type:
gflabel pred "{head(+)} {bolt(50,slotted,round)}\nM3×50"

And multiple label styles/symbol styles/fonts can be selected:
gflabel cullenect --font=Arial "M3×20{...}{cullbolt(+)}"

Here's a more complex example, generating a [Pred Gridfinity Storage Box][predbox] label. This uses multiple proportioned columns, symbols, and alignment:
gflabel predbox -w 5 "HEX\n{head(hex)} {bolt(5)}{3|}{<}M2\nM3\nM4\nM5{2|2}{<}M6\nM8\nM10\n"

This is an example of a Tailor Box label using multiple columns, rows, and symbols.
gflabel tailorbox -w=5 "M3 {|} Bolts Nuts\nWashers\n{hexhead(hex)} {hexhead(torx)} {nut} {washer}"

Command Parameters
The full command parameter usage (as generate by gflabel --help):
usage: gflabel [-h] [--vscode] [-w WIDTH] [--height HEIGHT] [--depth DEPTH_MM] [--no-overheight] [-d DIVISIONS] [--font FONT]
[--font-size-maximum FONT_SIZE_MAXIMUM | --font-size FONT_SIZE] [--font-style {regular,bold,italic}] [--font-path FONT_PATH]
[--margin MARGIN] [-o OUTPUT] [--style {embossed,debossed,embedded}] [--list-fragments] [--list-symbols] [--label-gap LABEL_GAP]
[--column-gap COLUMN_GAP] [--xscale XSCALE] [--yscale YSCALE] [--zscale ZSCALE] [-v] [--version VERSION]
BASE LABEL [LABEL ...]
Generate gridfinity bin labels
positional arguments:
BASE Label base to generate onto (pred, plain, none, cullenect, predbox).
LABEL
options:
-h, --help show this help message and exit
--vscode Run in vscode_ocp mode, and show the label afterwards.
-w WIDTH, --width WIDTH
Label width. If using a gridfinity standard base, then this is width in U. Otherwise, width in mm.
--height HEIGHT Label height, in mm. Ignored for standardised label bases.
--depth DEPTH_MM How high (or deep) the label extrusion is.
--no-overheight Disable the 'Overheight' system. This allows some symbols to oversize, meaning that the rest of the line will first shrink
before they are shrunk.
-d DIVISIONS, --divisions DIVISIONS
How many areas to divide a single label into. If more labels that this are requested, multiple labels will be generated.
Default: 1.
--font FONT The name of the system font to use for rendering. If unspecified, a bundled version of Open Sans will be used. Set GFLABEL_FONT
in your environment to change the default.
--font-size-maximum FONT_SIZE_MAXIMUM
Specify a maximum font size (in mm) to use for rendering. The text may end up smaller than this if it needs to fit in the area.
--font-size FONT_SIZE
The font size (in mm) to use for rendering. If unset, then the font will use as much vertical space as needed (that also fits
within the horizontal area).
--font-style {regular,bold,italic}
The font style use for rendering. [Default: regular]
--font-path FONT_PATH
Path to font file, if not using a system-level font.
--margin MARGIN The margin area (in mm) to leave around the label contents. Default is per-base.
-o OUTPUT, --output OUTPUT
Output filename(s). [Default: []]
--style {embossed,debossed,embedded}
How the label contents are formed.
--list-fragments List all available fragments.
--list-symbols List all available electronic symbols
--label-gap LABEL_GAP
Vertical gap (in mm) between physical labels. Default: 2 mm
--column-gap COLUMN_GAP
Gap (in mm) between columns
--xscale,--yscale,--zscale
Scale factor for entire label along the corresponding axis. Useful when you need slight adjustments for proper fit.
[All default to 1.0]
-v, --verbose Verbose output
--version VERSION The version of geometry to use for a given label system (if a system has versions). [Default: latest]
Defining Labels
Labels can consist of:
- A physical base, which is the object that the labels are extruded out of (or cut into).
- A label style, which specifies whether the label is raised out of, cut into, or flush with the surface of the base.
- Regular text, including unicode symbols (although complex symbols like emoji are unlikely to render properly, or at all - this is down to the underlying library).
- Newlines, either explicitly typed in (e.g. at the terminal), or escaped by
writing
\nin the label definition. Each line will be rendered separately, but still constrained to the same label area. - Fragments. These are directives enclosed in
{curly}braces that add symbols or define an area on the label.
Let's go through each of these:
Label Bases
The base (specified by --base=TYPE) defines the shape of what the label is generated on top of. Currently, the following bases are understood:
| Base | Description | Image |
| ---- | ----------- | ----- |
| 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). |
|
| 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. |
| 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. |
| plain | For a blank, square label wi
