3d-printing/gridfinity-box-label/label.scad
Felipe M. e13e743d9d
Add battery symbol and switch box label preset to "PILAS"
Add sym_battery to the shared label decoration library: an upright cell
with a solid terminal nub and "+"/"-" marks in the hollow body. Register
it in symbol_shape and add it to the customizer dropdowns of both the bin
label and the box label.

Switch the gridfinity-box-label customizer defaults to a centered "PILAS"
text flanked by two battery symbols, replacing the M2-M5 screw preset.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WMwnWKAqyrQveSoyi6o93
2026-09-09 22:31:46 +02:00

175 lines
6.5 KiB
OpenSCAD

// Label sized for the lid of a Gridfinity storage box. Uses the same
// Text/Symbol API as gridfinity-bin-label so the same icon catalogue applies.
use <../lib/label-decorations/label-decorations.scad>
/* [General Settings] */
// Quick-pick label length in Gridfinity units (overridden by labelXmm when use_preset is false)
grind_length = 5; // [4, 5, 7, 8]
// Use the grind_length preset for label length, otherwise drive size from labelXmm
use_preset = true;
// Width in mm (X dimension along the long edge of the label)
labelXmm = 67.5; // .1
// Height in mm (Y dimension along the short edge of the label)
labelYmm = 24.5; // .1
// Thickness in mm (Z dimension)
labelZmm = 0.85; // .01
// Subtract decorations from the label face instead of raising them
label_deboss = false;
/* [Label Text 1] */
// Multi-line text: use \n to split. Distance between line centers as a multiple of font size.
Text_Line_Spacing = 1.2; // .1
// Label Text
Text1 = "";
// Text Alignment
Text1_Align = "center"; // ["left","center","right"]
// Font Size
Text1_Font_Size = 6; // .1
// Font Family
Text1_Font = "Open Sans"; // [Open Sans, Open Sans Condensed, Ubuntu, Montserrat]
// Font Style
Text1_Font_Style = "Bold"; // [Regular,Black,Bold,ExtraBol,ExtraLight,Light,Medium,SemiBold,Thin,Italic,Black Italic,Bold Italic,ExtraBold Italic,ExtraLight Italic,Light Italic,Medium Italic,SemiBold Italic,Thin Italic]
// Adjust X and Y Position
Text1_XY = [0, 0]; // .1
/* [Label Text 2] */
// Label Text
Text2 = "PILAS";
// Text Alignment
Text2_Align = "center"; // ["left","center","right"]
// Font Size
Text2_Font_Size = 8; // .1
// Font Family
Text2_Font = "Open Sans"; // [Open Sans, Open Sans Condensed, Ubuntu, Montserrat]
// Font Style
Text2_Font_Style = "Bold"; // [Regular,Black,Bold,ExtraBol,ExtraLight,Light,Medium,SemiBold,Thin,Italic,Black Italic,Bold Italic,ExtraBold Italic,ExtraLight Italic,Light Italic,Medium Italic,SemiBold Italic,Thin Italic]
// Adjust X and Y Position
Text2_XY = [0, 0]; // .1
/* [Symbol 1] */
// Symbol shape (set to "none" to omit)
Symbol1 = "battery"; // [none, hex_rounded, hex_flat, phillips, slotted, torx, square, pozidriv, bit_phillips, bit_slotted, bit_hex, bit_torx, bit_square, bit_pozidriv, side_cap, side_flat, side_pan, side_button, side_hex, washer, nut, printer, magnet, battery]
// Symbol Alignment
Symbol1_Align = "left"; // ["left","center","right"]
// Symbol diameter in mm
Symbol1_Size = 14; // .1
// Stroke thickness for symbol details (cross, slot, star arms)
Symbol1_Stroke = 1.4; // .1
// Adjust X and Y Position
Symbol1_XY = [2, 0]; // .1
/* [Symbol 2] */
// Symbol shape (set to "none" to omit)
Symbol2 = "battery"; // [none, hex_rounded, hex_flat, phillips, slotted, torx, square, pozidriv, bit_phillips, bit_slotted, bit_hex, bit_torx, bit_square, bit_pozidriv, side_cap, side_flat, side_pan, side_button, side_hex, washer, nut, printer, magnet, battery]
// Symbol Alignment
Symbol2_Align = "right"; // ["left","center","right"]
// Symbol diameter in mm
Symbol2_Size = 14; // .1
// Stroke thickness for symbol details (cross, slot, star arms)
Symbol2_Stroke = 1.4; // .1
// Adjust X and Y Position
Symbol2_XY = [-2, 0]; // .1
/* [Advanced] */
// Corner radius of the chamfered base
corner_radius = 3.5;
// Chamfer applied to top and bottom edges
chamfer_size = 0.2;
$fs = 0.1;
$fa = 5;
/* [Hidden] */
function preset_length(units) =
(units == 4) ? 25.5 :
(units == 5) ? 67.5 :
(units == 7) ? 82 :
(units == 8) ? 100 : 67.5;
labelX = use_preset ? preset_length(grind_length) : labelXmm;
labelY = labelYmm;
labelZ = labelZmm;
decoration_extrude = 0.4;
// Decoration extrusion straddles the top face: 0.2 mm below the surface and
// 0.2 mm above. Raised mode shows the upper half; deboss mode carves the lower.
decoration_z = labelZ - 0.2;
// Chamfered base shape (top + bottom chamfers around a flat slab)
module label_base() {
color("Silver")
union() {
translate([0, 0, 0])
chamfer_layer(labelX, labelY, chamfer_size, corner_radius, flip = false);
translate([0, 0, chamfer_size])
rounded_slab(labelX, labelY, labelZ - 2 * chamfer_size, corner_radius);
translate([0, 0, labelZ - chamfer_size])
chamfer_layer(labelX, labelY, chamfer_size, corner_radius, flip = true);
}
}
module rounded_slab(length, width, height, radius) {
hull() {
translate([radius, radius, 0]) cylinder(h = height, r = radius);
translate([radius, width - radius, 0]) cylinder(h = height, r = radius);
translate([length - radius, width - radius, 0]) cylinder(h = height, r = radius);
translate([length - radius, radius, 0]) cylinder(h = height, r = radius);
}
}
module chamfer_layer(length, width, size, radius, flip) {
r1 = flip ? radius : radius - size;
r2 = flip ? radius - size : radius;
hull() {
translate([radius, radius, 0]) cylinder(h = size, r1 = r1, r2 = r2);
translate([radius, width - radius, 0]) cylinder(h = size, r1 = r1, r2 = r2);
translate([length - radius, width - radius, 0]) cylinder(h = size, r1 = r1, r2 = r2);
translate([length - radius, radius, 0]) cylinder(h = size, r1 = r1, r2 = r2);
}
}
// Combined text + symbol overlay using shared helpers
module label_decorations() {
color("Gray") {
label_text(Text1,
text_x(Text1_Align, Text1_XY.x, labelX),
(labelY / 2) + Text1_XY.y, decoration_z,
Text1_Font_Size, Text1_Font, Text1_Font_Style, Text1_Align,
decoration_extrude,
Text1_Font_Size * Text_Line_Spacing);
label_text(Text2,
text_x(Text2_Align, Text2_XY.x, labelX),
(labelY / 2) + Text2_XY.y, decoration_z,
Text2_Font_Size, Text2_Font, Text2_Font_Style, Text2_Align,
decoration_extrude,
Text2_Font_Size * Text_Line_Spacing);
label_symbol(Symbol1,
symbol_x(Symbol1_Align, Symbol1_Size, Symbol1_XY.x, labelX),
(labelY / 2) + Symbol1_XY.y, decoration_z,
Symbol1_Size, Symbol1_Stroke, decoration_extrude);
label_symbol(Symbol2,
symbol_x(Symbol2_Align, Symbol2_Size, Symbol2_XY.x, labelX),
(labelY / 2) + Symbol2_XY.y, decoration_z,
Symbol2_Size, Symbol2_Stroke, decoration_extrude);
}
}
module box_label() {
if (label_deboss) {
difference() {
label_base();
label_decorations();
}
} else {
union() {
label_base();
label_decorations();
}
}
}
box_label();