-
Notifications
You must be signed in to change notification settings - Fork 152
Tutorial Attachment Edge Profiling
You can use attachment in various ways to create edge profiles on
objects. One method is to simply attach an edge mask to the edge of a
parent object while using diff()
so that the mask creates the
desired edge profile. Most objects set the $edge_angle
and
$edge_length
variables so make this easier to do.
Another way to apply edge treatments is to use some specialized
modules for applying masks. Modules such as edge_mask()
can for working with 3D masks,
which may potentially change across their length. Modules like
edge_profile()
can extrude a 2D profile along specified edges.
To make it easier to mask away shapes from various edges of an attachable parent shape, there
are a few specialized alternatives to the attach()
and position()
modules.
If you have a 3D mask shape that you want to difference away from various edges, you can use
the edge_mask()
module. This module will take a vertically oriented shape, and will rotate
and move it such that the BACK, RIGHT (X+,Y+) side of the shape will be aligned with the given
edges. The shape will be tagged as a "remove" so that you can use
diff()
with its default "remove" tag. For example,
here's a shape for rounding an edge:
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));
}
round_edge(l=30, r=19);
You can use that mask to round various edges of a cube:
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);
If you have a 3D mask shape that you want to difference away from various corners, you can use
the corner_mask()
module. This module will take a shape and rotate and move it such that the
BACK RIGHT TOP (X+,Y+,Z+) side of the shape will be aligned with the given corner. The shape
will be tagged as a "remove" so that you can use diff()
with its
default "remove" tag. For example, here's a shape for
rounding a corner:
include <BOSL2/std.scad>
module round_corner(r) difference() {
translate(-[1,1,1])
cube(r+1);
translate([r,r,r])
spheroid(r=r, style="aligned", $fn=quantup(segs(r),4));
}
round_corner(r=10);
You can use that mask to round various corners of a cube:
include <BOSL2/std.scad>
module round_corner(r) difference() {
translate(-[1,1,1])
cube(r+1);
translate([r,r,r])
spheroid(r=r, style="aligned", $fn=quantup(segs(r),4));
}
diff()
cube([50,60,70],center=true)
corner_mask([TOP,FRONT],LEFT+FRONT+TOP)
round_corner(r=10);
You can use edge_mask()
and corner_mask()
together as well:
include <BOSL2/std.scad>
module round_corner(r) difference() {
translate(-[1,1,1])
cube(r+1);
translate([r,r,r])
spheroid(r=r, style="aligned", $fn=quantup(segs(r),4));
}
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("ALL") round_edge(l=71,r=10);
corner_mask("ALL") round_corner(r=10);
}
While 3D mask shapes give you a great deal of control, you need to make sure they are correctly
sized, and you need to provide separate mask shapes for corners and edges. Often, a single 2D
profile could be used to describe the edge mask shape (via linear_extrude()
), and the corner
mask shape (via rotate_extrude()
). This is where edge_profile()
, corner_profile()
, and
face_profile()
come in.
Using the edge_profile()
module, you can provide a 2D profile shape and it will be linearly
extruded to a mask of the appropriate length for each given edge. The resultant mask will be
tagged with "remove" so that you can difference it away with diff()
with the default "remove" tag. The 2D profile is
assumed to be oriented with the BACK, RIGHT (X+,Y+) quadrant as the "cutter edge" that gets
re-oriented towards the edges of the parent shape. A typical mask profile for chamfering an
edge may look like:
include <BOSL2/std.scad>
mask2d_roundover(10);
Using that mask profile, you can mask the edges of a cube like:
include <BOSL2/std.scad>
diff()
cube([50,60,70],center=true)
edge_profile("ALL")
mask2d_roundover(10);
You can use the same profile to make a rounded corner mask as well:
include <BOSL2/std.scad>
diff()
cube([50,60,70],center=true)
corner_profile("ALL", r=10)
mask2d_roundover(10);
As a simple shortcut to apply a profile mask to all edges and corners of a face, you can use the
face_profile()
module:
include <BOSL2/std.scad>
diff()
cube([50,60,70],center=true)
face_profile(TOP, r=10)
mask2d_roundover(10);
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
- drawing.scad STD
- masks2d.scad STD
- masks3d.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
STD = Included in std.scad