一键导入
bosl2-attachment
Understand key concepts behind BOSL2's attachable/anchor system, including how to position parts reliably on faces, edges, and corners.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Understand key concepts behind BOSL2's attachable/anchor system, including how to position parts reliably on faces, edges, and corners.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | bosl2-attachment |
| title | BOSL2 Attachment System |
| description | Understand key concepts behind BOSL2's attachable/anchor system, including how to position parts reliably on faces, edges, and corners. |
Teach how BOSL2's attachable/anchor system works so parts are positioned reliably on faces, edges, and corners.
BOSL2 is an OpenSCAD library that provides a collection of modules for creating complex geometries, including an attachment system for positioning parts. This skill focuses on understanding the core concepts of BOSL2's attachment system, including anchors, attachable parents/children, orientation control, and common pitfalls.
BOSL2 uses named directions as anchors:
TOP, BOTTOM, LEFT, RIGHT, FWD, BACK+, e.g. TOP+RIGHT, TOP+FWD+RIGHTImportant:
TOP+RIGHT is one edge anchor (single combined anchor)[TOP, RIGHT] is an array of two separate anchors (used when a function accepts multiple anchors)Examples:
attach(RIGHT) = attach on right faceattach(TOP+FWD+RIGHT) = top-front-right cornerAttaching works when the parent is attachable (e.g., cuboid() from BOSL2).
Inside a block, each attach() is anchored to the parent:
cuboid([50,15,25]) {
attach(RIGHT) sphere(d=5);
attach(LEFT) sphere(d=5);
}
This chains to the previous child, not back to parent:
cuboid([50,15,25])
attach(RIGHT) thing1()
attach(LEFT) thing2(); // often attaches to thing1 context
Use block form to avoid this:
cuboid([50,15,25]) {
attach(RIGHT) thing1();
attach(LEFT) thing2();
}
attach(parent, child, spin=...)attach() controls both placement and rotation.
For predictable orientation, prefer the two-anchor form:
attach(parent_anchor, child_anchor, spin=...)
Examples:
attach(TOP, BOTTOM) -> put child's bottom onto parent's topattach(RIGHT, BOTTOM) -> put child's bottom onto parent's right faceNotes:
TOP/BOTTOM generally preserves the child's back direction.LEFT/RIGHT/FWD/BACK) often needs spin= to get desired roll/twist.spin= in attach() rotates around the attachment vector.Example with explicit face-to-face and spin:
cuboid([60,20,20]) {
attach(TOP, BOTTOM) cylinder(d=10, h=8);
attach(RIGHT, BOTTOM, spin=90) prismoid([12,8],[8,8],h=6);
}
attach() and child anchor/orientSingle-argument attach respects the child's own anchor= and orient=:
cuboid([50,15,25])
attach(TOP)
cyl(h=8, d=10, anchor=BOTTOM, orient=UP);
Use this when the child module already exposes good anchor/orient controls.
diff() + Attachdiff() subtracts attached geometry from parent when used in BOSL2 style:
diff()
cuboid([50,15,25]) {
attach(RIGHT) cutter_shape();
}
cuboid([50,15,25]) {
attach(RIGHT) feature_a();
attach(LEFT) feature_b();
}
cuboid([50,15,25]) {
attach(TOP+FWD+RIGHT) feature();
}
cuboid([200,150,12], anchor=CENTER)
attach(TOP, spin=90)
isogrid_rect(200,150, triangle_size=20, thickness=1.5, extrude=1);
FWD vs BACK, LEFT vs RIGHT){ ... } block on parentattach(parent, child)) and add spin=anchor=/orient= explicitly