Loading...
Loading...
Adds text labels to OpenSCAD 3D models using BOSL2's face/anchor system and specialized labeling libraries. Use when you need to label model faces, add part numbers, create dimension annotations, or wrap text on curved surfaces. Triggers on "label this model", "add text to face", "how do I label in OpenSCAD", "text on cylinder", "attach text to TOP face", or "install text libraries". Works with .scad files, BOSL2, text_on_OpenSCAD, attachable_text3d, and Write.scad libraries.
npx skill4agent add dawiddutoit/custom-claude openscad-labelinginclude <BOSL2/std.scad>
cuboid([50, 30, 20])
attach(TOP, BOT)
linear_extrude(2)
text("TOP", size=8, halign="center", valign="center");include <BOSL2/std.scad>
// The six primary faces
TOP, BOTTOM, LEFT, RIGHT, FRONT, BACK| Face | Direction | Normal Vector | Notes |
|---|---|---|---|
| TOP | +Z | [0, 0, 1] | Points up |
| BOTTOM | -Z | [0, 0, -1] | Points down |
| FRONT | -Y | [0, -1, 0] | Points toward viewer |
| BACK | +Y | [0, 1, 0] | Points away |
| LEFT | -X | [-1, 0, 0] | Points left |
| RIGHT | +X | [1, 0, 0] | Points right |
cuboid([50, 30, 20]) {
attach(TOP) color("red") cuboid([10, 10, 5]);
attach(FRONT) color("blue") cyl(d=8, h=3);
attach(LEFT+BOTTOM) color("green") sphere(d=5);
}// Edges (combine two faces)
TOP+LEFT, BOTTOM+RIGHT, FRONT+TOP
// Corners (combine three faces)
TOP+LEFT+FRONT, BOTTOM+RIGHT+BACKinclude <BOSL2/std.scad>
cuboid([50, 30, 20])
attach(TOP, BOT)
linear_extrude(2)
text("LABEL", size=8, halign="center", valign="center");attach(TOP, BOT)linear_extrude(2)halign="center", valign="center"include <BOSL2/std.scad>
diff()
cuboid([50, 30, 20])
attach(TOP, BOT, inside=true)
tag("remove")
linear_extrude(1)
text("CUT", size=8, halign="center", valign="center");diff()inside=truetag("remove")include <BOSL2/std.scad>
module labeled_box(size, labels) {
faces = [TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT];
diff()
cuboid(size)
for (i = [0:5])
if (labels[i] != "")
attach(faces[i], BOT)
tag("remove")
linear_extrude(1)
text(labels[i], size=size.x/8, halign="center", valign="center");
}
labeled_box([50, 30, 20], ["TOP", "BOT", "FRONT", "BACK", "L", "R"]);include <BOSL2/std.scad>
module part_label(txt, size=[40, 15, 2]) {
diff()
cuboid(size, rounding=1, edges="Z")
attach(TOP, BOT, inside=true)
tag("remove")
linear_extrude(0.5)
text(txt, size=size.y*0.5, halign="center", valign="center");
}
part_label("PN-001");ls ~/Documents/OpenSCAD/libraries/text_on_OpenSCAD
ls ~/Documents/OpenSCAD/libraries/openscad_attachable_text3duse <text_on_OpenSCAD/text_on.scad>
// Text wrapped around cylinder
text_on_cylinder("LABEL", r=15, h=30, size=4, font="Liberation Sans");
// Text on sphere surface
text_on_sphere("Hello World", r=20, size=5);
// Text on cube face (alternative to BOSL2)
text_on_cube("FRONT", size=8, face="front", cube_size=50);include <BOSL2/std.scad>
use <openscad_attachable_text3d/attachable_text3d.scad>
// Attachable 3D text with accurate font metrics
cuboid([50, 30, 20])
attach(TOP)
attachable_text3d("Label", size=10, h=2);use <Write.scad>
// Text on cube faces
writecube("TEXT", [50, 30, 20], face="front", t=2, h=8);
// Text on sphere
writesphere("GLOBE", 25, t=2, h=6);
// Text on cylinder
writecylinder("LABEL", r=15, h=30, t=2);cd ~/Documents/OpenSCAD/libraries # macOS
# cd ~/.local/share/OpenSCAD/libraries # Linux
git clone https://github.com/brodykenrick/text_on_OpenSCAD.gituse <text_on_OpenSCAD/text_on.scad>
text_on_cylinder("TEST", r=10, h=20, size=3);cd ~/Documents/OpenSCAD/libraries
git clone https://github.com/jon-gilbert/openscad_attachable_text3d.gitinclude <BOSL2/std.scad>
use <openscad_attachable_text3d/attachable_text3d.scad>
attachable_text3d("TEST", size=10, h=2);ls -la ~/Documents/OpenSCAD/libraries/references/library-comparison.mdreferences/font-reference.mdexamples/practical-labels.scadexamples/curved-text.scadexamples/engraved-embossed.scadscripts/check-text-libraries.shscripts/list-system-fonts.shinclude <BOSL2/std.scad>
cuboid([50, 30, 20])
attach(TOP, BOT)
linear_extrude(2)
text("SUCCESS", size=6, halign="center", valign="center");// ❌ WRONG: Manual positioning without BOSL2
cube([50, 30, 20]);
translate([25, 15, 20]) // Easy to miscalculate
linear_extrude(2)
text("WRONG", size=6, halign="center");attach(TOP, BOT)attach(TOP, TOP)Need text on model?
├─ Flat surface?
│ ├─ Using BOSL2? → attach() + text()
│ └─ Not using BOSL2? → text_on_OpenSCAD or Write.scad
└─ Curved surface (cylinder/sphere)?
├─ BOSL2 workflow? → attachable_text3d (if installed)
└─ Classic approach? → text_on_OpenSCAD or Write.scad$fn=$preview ? 32 : 64