| name | openscad-bosl2-mastery |
| description | Use when Gemini CLI is implementing geometry using the BOSL2 library. |
OpenSCAD BOSL2 Mastery
Note: This content was generated with the assistance of AI.
Overview
A guide to mastering the Belfry OpenSCAD Library v2 (BOSL2), focusing on intent-based positioning and advanced primitives.
Key Concepts
Attachments & Anchors
- Attachments: Position objects relative to each other using the
attach module.
- Anchors: Named points on a shape (e.g.,
TOP, BOTTOM, LEFT, RIGHT, FRONT, BACK).
- Syntax:
attach(TOP) cuboid([10, 10, 5]); to place a cuboid on the top face of the parent.
Shorthands (Commonly Used)
up(z): Equivalent to translate([0,0,z]).
left(x): Equivalent to translate([-x,0,0]).
right(x): Equivalent to translate([x,0,0]).
fwd(y): Equivalent to translate([0,-y,0]).
back(y): Equivalent to translate([0,y,0]).
xrot(angle), yrot(angle), zrot(angle): Axis-specific rotations.
Extended Primitives
cuboid([w, d, h], rounding=r, edges=[TOP, FRONT]): Cube with built-in rounding.
cyl(h=h, d=d, rounding1=r1, rounding2=r2): Cylinder with rounded ends.
Best Practices
- Avoid
translate: Use up, down, left, right for clarity.
- Prioritize
attach: Use it for all relative positioning to ensure the model remains parametric.
- Use
std.scad: Always include <BOSL2/std.scad> to get all core features.
Advanced Techniques
- Masking: Use the
mask2d and mask3d modules for complex edge subtractions.
- VNFs: Use for high-performance custom polyhedra.