-
Notifications
You must be signed in to change notification settings - Fork 187
Tutorial Edge_Face_Sets
When working with BOSL2 shapes like cuboid(), you often want to round or chamfer
only specific edges, or apply masks to certain faces. BOSL2 provides a flexible system
for selecting edges and faces using direction vectors and string constants.
This tutorial explains how to specify which edges and faces you want to operate on.
A face on a cube-like shape is identified by a single direction unit vector pointing toward that face. For convenience, all six faces of a cube have easy to remember names associated with them. The six faces and their vector names are:
| Name | Vector | Description |
|---|---|---|
LEFT |
[-1,0,0] |
Left face (-X) |
RIGHT |
[1,0,0] |
Right face (+X) |
FRONT / FWD
|
[0,-1,0] |
Front face (-Y) |
BACK |
[0,1,0] |
Back face (+Y) |
BOTTOM / BOT / DOWN
|
[0,0,-1] |
Bottom face (-Z) |
TOP / UP
|
[0,0,1] |
Top face (+Z) |
A cube has 12 edges. BOSL2 identifies each edge by combining two face direction
vectors. For example, the edge where the TOP and FRONT faces meet is TOP+FRONT.
The 12 edges of a cube, grouped by level are:
Top edges:
TOP+FRONTTOP+BACKTOP+LEFTTOP+RIGHT
Bottom edges:
BOT+FRONTBOT+BACKBOT+LEFTBOT+RIGHT
Vertical edges:
FRONT+LEFTFRONT+RIGHTBACK+LEFTBACK+RIGHT
Some shapes in BOSL2 offer rounding or chamfering of their edges. In cuboid(), for example, you can add a rounding=10 argument,
to cause the cuboid's edges to be rounded to 10 units radius. By default, all edges will be rounded, but you may only want to round
one of the edges. Using the edges= argument, you can specify which edge by summing two adjacent face vectors:
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges=TOP+FRONT);
If you want to specify more than one edge, you can make a list of edges:
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges=[TOP+FRONT, RIGHT+FRONT]);
You can select as many edges as you want:
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges=[TOP+FRONT, RIGHT+FRONT, BOTTOM+FRONT]);
A single face vector selects all four edges surrounding that face:
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges=TOP);
This rounds all four edges around the top face. Similarly, edges=FRONT selects
the four edges around the front face.
You can also specify multiple faces in a list, to select all edges around any of them:
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges=[TOP,RIGHT]);
A corner vector (sum of three face vectors) selects the three edges meeting at that corner:
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges=FRONT+RIGHT+TOP);
Again, you can make a list of corners to select all edges around any of the corners.
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges=[FRONT+RIGHT+TOP, FRONT+LEFT+TOP]);
You can use string shortcuts to select all edges aligned with a given axis:
| String | Selects |
|---|---|
"X" |
All 4 edges parallel to the X axis |
"Y" |
All 4 edges parallel to the Y axis |
"Z" |
All 4 edges parallel to the Z axis (vertical) |
"ALL" |
All 12 edges |
"NONE" |
No edges |
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges="Z");
This rounds only the four vertical edges.
Again, you can use a list to select multiple of these:
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges=["Y","Z"]);
You can mix and match any or all of the above described edge descriptors in a list, and BOSL2 will combine them in a union:
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=5, edges=[TOP, FRONT+RIGHT]);
This rounds all edges around the top face, plus the single vertical edge at the front-right.
This can even be done with the axis aligned edge descriptors:
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=5, edges=[TOP, "Z"]);
This rounds all the edges around the top face, and all the vertical edges.
Use except to remove specific edges from the selection. This is often simpler
than listing every edge you want to keep:
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges="ALL", except=[BOT, FRONT+LEFT]);
This rounds all edges except those around the bottom face and the front-left vertical edge.
The except parameter accepts the same descriptors as edges: individual edges,
face vectors, corner vectors, and axis strings.
include <BOSL2/std.scad>
cuboid([50,60,70], rounding=10, edges=TOP, except=TOP+BACK);
This rounds the top face edges, except for the top-back edge.
The same edge selection system works with the chamfer parameter on cuboid():
include <BOSL2/std.scad>
cuboid([50,60,70], chamfer=5, edges=[TOP+FRONT, TOP+RIGHT, FRONT+RIGHT]);
The edge_mask() and edge_profile() modules also use edge set descriptors
to control which edges receive a mask.
Extrudes a 2D profile along selected edges. Here, we're diffing the resulting extruded mask away:
include <BOSL2/std.scad>
diff()
cube([50,60,70], center=true)
edge_profile([TOP, "Z"], except=[BACK, TOP+LEFT])
mask2d_roundover(10);
Positions a 3D mask shape along selected edges:
include <BOSL2/std.scad>
module round_edge(l, r) difference() {
translate([-1,-1,-l/2])
cube([r+1, r+1, l]);
translate([r, r])
cylinder(h=l+1, r=r, center=true, $fn=quantup(segs(r),4));
}
diff()
cube([50,60,70], center=true)
edge_mask([TOP, "Z"], except=[BACK, TOP+LEFT])
round_edge(l=71, r=10);
Face vectors can be used with modules like face_profile() to apply a 2D mask
profile to all edges and corners of a given face:
include <BOSL2/std.scad>
diff()
cube([50,60,70], center=true)
face_profile(TOP, r=10)
mask2d_roundover(10);
A common pattern for enclosures: round only the top edges.
include <BOSL2/std.scad>
cuboid([60,40,30], rounding=5, edges=TOP);
Useful for grip surfaces or decorative columns:
include <BOSL2/std.scad>
cuboid([30,30,60], chamfer=3, edges="Z");
A box that sits flat on the build plate:
include <BOSL2/std.scad>
cuboid([50,40,25], rounding=4, edges="ALL", except=BOT);
| Descriptor | What it selects |
|---|---|
TOP+FRONT |
A single edge |
TOP |
All 4 edges around the top face |
FRONT+LEFT+TOP |
All 3 edges at a corner |
"X", "Y", "Z"
|
All 4 edges along an axis |
"ALL" |
All 12 edges |
"NONE" |
No edges |
except=BOT |
Remove bottom edges from selection |
These selectors work consistently across cuboid(), edge_mask(),
edge_profile(), corner_mask(), corner_profile(), and face_profile().
Table of Contents
Function Index
Topics Index
Glossary
Cheat Sheet
Tutorials
Basic Modeling:
- constants.scad STD
- transforms.scad STD
- attachments.scad STD
- shapes2d.scad STD
- shapes3d.scad STD
- masks.scad STD
- drawing.scad STD
- distributors.scad STD
- color.scad STD
- partitions.scad STD
- miscellaneous.scad STD
Advanced Modeling:
- paths.scad STD
- regions.scad STD
- skin.scad STD
- vnf.scad STD
- beziers.scad STD
- nurbs.scad
- rounding.scad STD
- turtle3d.scad
- isosurface.scad
Math:
- math.scad STD
- linalg.scad STD
- vectors.scad STD
- coords.scad STD
- geometry.scad STD
- trigonometry.scad STD
Data Management:
- version.scad STD
- comparisons.scad STD
- lists.scad STD
- utility.scad STD
- strings.scad STD
- structs.scad STD
- fnliterals.scad
Threaded Parts:
Parts:
- ball_bearings.scad
- cubetruss.scad
- gears.scad
- hinges.scad
- joiners.scad
- linear_bearings.scad
- modular_hose.scad
- nema_steppers.scad
- polyhedra.scad
- sliders.scad
- tripod_mounts.scad
- walls.scad
- wiring.scad
- hooks.scad
STD = Included in std.scad