Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Adrian Mariano 2023-10-04 23:57:01 -04:00
commit d252a63279
3 changed files with 193 additions and 121 deletions

View file

@ -1543,8 +1543,7 @@ module face_mask(faces=[LEFT,RIGHT,FRONT,BACK,BOT,TOP]) {
assert(all([for (face=faces) is_vector(face) && sum([for (x=face) x!=0? 1 : 0])==1]), "Vector in faces doesn't point at a face.");
assert($parent_geom != undef, "No object to attach to!");
attach(faces) {
if ($tag=="") tag("remove") children();
else children();
default_tag("remove") children();
}
}
@ -1576,8 +1575,6 @@ module face_mask(faces=[LEFT,RIGHT,FRONT,BACK,BOT,TOP]) {
// except = Edges to explicitly NOT mask. See [Specifying Edges](attachments.scad#subsection-specifying-edges). Default: No edges.
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// `$idx` is set to the index number of each edge.
// `$attach_anchor` is set for each edge given, to the `[ANCHOR, POSITION, ORIENT, SPIN]` information for that anchor.
// Example:
@ -1608,8 +1605,7 @@ module edge_mask(edges=EDGES_ALL, except=[]) {
vec.z==0 && sign(vec.x)!=sign(vec.y)? [0,180,45+v_theta(vec)] :
[-90,0,180+v_theta(vec)];
translate(anch[1]) rot(rotang)
if ($tag=="") tag("remove") children();
else children();
default_tag("remove") children();
}
}
@ -1659,8 +1655,7 @@ module corner_mask(corners=CORNERS_ALL, except=[]) {
[ 0,0,180+v_theta(vec)-45] :
[180,0,-90+v_theta(vec)-45];
translate(anch[1]) rot(rotang)
if ($tag=="") tag("remove") children();
else children();
default_tag("remove") children();
}
}
@ -2167,7 +2162,7 @@ module edge_profile_asym(
// d = Diameter of corner mask.
// convexity = Max number of times a line could intersect the perimeter of the mask shape. Default: 10
// Side Effects:
// Tags the children with "remove" (and hence sets $tag) if no tag is already set.
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// `$idx` is set to the index number of each corner.
// `$attach_anchor` is set for each corner given, to the `[ANCHOR, POSITION, ORIENT, SPIN]` information for that anchor.
// `$profile_type` is set to `"corner"`.
@ -2195,7 +2190,7 @@ module corner_profile(corners=CORNERS_ALL, except=[], r, d, convexity=10) {
rotang = vec.z<0?
[ 0,0,180+v_theta(vec)-45] :
[180,0,-90+v_theta(vec)-45];
$tag = $tag=="" ? str($tag_prefix,"remove") : $tag;
default_tag("remove"){
translate(anch[1]) {
rot(rotang) {
down(0.01) {
@ -2217,6 +2212,7 @@ module corner_profile(corners=CORNERS_ALL, except=[], r, d, convexity=10) {
}
}
}
}
// Section: Making your objects attachable

View file

@ -37,6 +37,9 @@
// d = Diameter of the roundover.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
//
// Example(2D): 2D Roundover Mask
// mask2d_roundover(r=10);
// Example(2D): 2D Bead Mask
@ -60,11 +63,13 @@
// mask2d_roundover(r=10);
module mask2d_roundover(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENTER,spin=0) {
path = mask2d_roundover(r=r, d=d, inset=inset, mask_angle=mask_angle, excess=excess);
default_tag("remove") {
attachable(anchor,spin, two_d=true, path=path) {
polygon(path);
children();
}
}
}
function mask2d_roundover(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENTER, spin=0) =
assert(is_finite(r)||is_finite(d))
@ -114,6 +119,8 @@ function mask2d_roundover(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENT
// d = Diameter of the cove.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example(2D): 2D Cove Mask
// mask2d_cove(r=10);
// Example(2D): 2D Inset Cove Mask
@ -137,11 +144,13 @@ function mask2d_roundover(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENT
// mask2d_cove(r=5, inset=5);
module mask2d_cove(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENTER, spin=0) {
path = mask2d_cove(r=r, d=d, inset=inset, mask_angle=mask_angle, excess=excess);
default_tag("remove") {
attachable(anchor,spin, two_d=true, path=path) {
polygon(path);
children();
}
}
}
function mask2d_cove(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENTER, spin=0) =
assert(is_finite(r)||is_finite(d))
@ -198,6 +207,8 @@ function mask2d_cove(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENTER, s
// y = The height of the chamfer.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example(2D): 2D Chamfer Mask
// mask2d_chamfer(x=10);
// Example(2D): 2D Chamfer Mask by Width.
@ -221,11 +232,13 @@ function mask2d_cove(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENTER, s
// mask2d_chamfer(edge=10);
module mask2d_chamfer(edge, angle=45, inset=0, excess=0.01, x, y, anchor=CENTER,spin=0) {
path = mask2d_chamfer(x=x, y=y, edge=edge, angle=angle, excess=excess, inset=inset);
default_tag("remove") {
attachable(anchor,spin, two_d=true, path=path, extent=true) {
polygon(path);
children();
}
}
}
function mask2d_chamfer(edge, angle=45, inset=0, excess=0.01, x, y, anchor=CENTER,spin=0) =
let(dummy=one_defined([x,y,edge],["x","y","edge"]))
@ -269,6 +282,8 @@ function mask2d_chamfer(edge, angle=45, inset=0, excess=0.01, x, y, anchor=CENTE
// ---
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example(2D): 2D Rabbet Mask
// mask2d_rabbet(size=10);
// Example(2D): 2D Asymmetrical Rabbet Mask
@ -290,11 +305,13 @@ function mask2d_chamfer(edge, angle=45, inset=0, excess=0.01, x, y, anchor=CENTE
// mask2d_rabbet(size=[5,10]);
module mask2d_rabbet(size, mask_angle=90, excess=0.01, anchor=CTR, spin=0) {
path = mask2d_rabbet(size=size, mask_angle=mask_angle, excess=excess);
default_tag("remove") {
attachable(anchor,spin, two_d=true, path=path, extent=false) {
polygon(path);
children();
}
}
}
function mask2d_rabbet(size, mask_angle=90, excess=0.01, anchor=CTR, spin=0) =
assert(is_finite(size)||(is_vector(size)&&len(size)==2))
@ -344,6 +361,8 @@ function mask2d_rabbet(size, mask_angle=90, excess=0.01, anchor=CTR, spin=0) =
// y = The height of the dovetail.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example(2D): 2D Dovetail Mask
// mask2d_dovetail(x=10);
// Example(2D): 2D Dovetail Mask by Width.
@ -367,11 +386,13 @@ function mask2d_rabbet(size, mask_angle=90, excess=0.01, anchor=CTR, spin=0) =
// mask2d_dovetail(x=10);
module mask2d_dovetail(edge, angle=30, inset=0, shelf=0, excess=0.01, x, y, anchor=CENTER, spin=0) {
path = mask2d_dovetail(x=x, y=y, edge=edge, angle=angle, inset=inset, shelf=shelf, excess=excess);
default_tag("remove") {
attachable(anchor,spin, two_d=true, path=path) {
polygon(path);
children();
}
}
}
function mask2d_dovetail(edge, angle=30, inset=0, shelf=0, excess=0.01, x, y, anchor=CENTER, spin=0) =
assert(num_defined([x,y,edge])==1)
@ -420,6 +441,8 @@ function mask2d_dovetail(edge, angle=30, inset=0, shelf=0, excess=0.01, x, y, an
// d = Diameter of the rounding.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example(2D): 2D Teardrop Mask
// mask2d_teardrop(r=10);
// Example(2D): 2D Teardrop Mask for a Non-Right Edge
@ -469,11 +492,13 @@ function mask2d_teardrop(r, angle=45, mask_angle=90, excess=0.01, d, anchor=CENT
module mask2d_teardrop(r, angle=45, mask_angle=90, excess=0.01, d, anchor=CENTER, spin=0) {
path = mask2d_teardrop(r=r, d=d, angle=angle, mask_angle=mask_angle, excess=excess);
default_tag("remove") {
attachable(anchor,spin, two_d=true, path=path) {
polygon(path);
children();
}
}
}
// Function&Module: mask2d_ogee()
// Synopsis: Creates a 2D ogee mask shape.
@ -510,6 +535,9 @@ module mask2d_teardrop(r, angle=45, mask_angle=90, excess=0.01, d, anchor=CENTER
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
//
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
//
// Example(2D): 2D Ogee Mask
// mask2d_ogee([
// "xstep",1, "ystep",1, // Starting shoulder.
@ -539,11 +567,13 @@ module mask2d_teardrop(r, angle=45, mask_angle=90, excess=0.01, d, anchor=CENTER
// ]);
module mask2d_ogee(pattern, excess=0.01, anchor=CENTER,spin=0) {
path = mask2d_ogee(pattern, excess=excess);
default_tag("remove") {
attachable(anchor,spin, two_d=true, path=path) {
polygon(path);
children();
}
}
}
function mask2d_ogee(pattern, excess=0.01, anchor=CENTER, spin=0) =
assert(is_list(pattern))

View file

@ -17,7 +17,7 @@
// Synopsis: Creates a shape to chamfer a 90° edge.
// SynTags: Geom
// Topics: Masking, Chamfers, Shapes (3D)
// See Also: chamfer_corner_mask(), chamfer_cylinder_mask(), chamfer_edge_mask()
// See Also: chamfer_corner_mask(), chamfer_cylinder_mask(), chamfer_edge_mask(), default_tag(), diff()
// Usage:
// chamfer_edge_mask(l|h=|length=|height=, chamfer, [excess]) [ATTACHMENTS];
// Description:
@ -32,6 +32,8 @@
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example:
// chamfer_edge_mask(l=50, chamfer=10);
// Example:
@ -48,18 +50,20 @@
function chamfer_edge_mask(l, chamfer=1, excess=0.1, h, length, height, anchor=CENTER, spin=0, orient=UP) = no_function("chamfer_edge_mask");
module chamfer_edge_mask(l, chamfer=1, excess=0.1, h, length, height, anchor=CENTER, spin=0, orient=UP) {
l = one_defined([l, h, height, length], "l,h,height,length");
default_tag("remove") {
attachable(anchor,spin,orient, size=[chamfer*2, chamfer*2, l]) {
cylinder(r=chamfer, h=l+excess, center=true, $fn=4);
children();
}
}
}
// Module: chamfer_corner_mask()
// Synopsis: Creates a shape to chamfer a 90° corner.
// SynTags: Geom
// Topics: Masking, Chamfers, Shapes (3D)
// See Also: chamfer_corner_mask(), chamfer_cylinder_mask(), chamfer_edge_mask()
// See Also: chamfer_corner_mask(), chamfer_cylinder_mask(), chamfer_edge_mask(), default_tag(), diff()
// Usage:
// chamfer_corner_mask(chamfer) [ATTACHMENTS];
// Description:
@ -72,6 +76,8 @@ module chamfer_edge_mask(l, chamfer=1, excess=0.1, h, length, height, anchor=CEN
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example:
// chamfer_corner_mask(chamfer=10);
// Example:
@ -90,15 +96,17 @@ module chamfer_edge_mask(l, chamfer=1, excess=0.1, h, length, height, anchor=CEN
// show_anchors();
function chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) = no_function("chamfer_corner_mask");
module chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) {
default_tag("remove") {
octahedron(chamfer*4, anchor=anchor, spin=spin, orient=orient) children();
}
}
// Module: chamfer_cylinder_mask()
// Synopsis: Creates a shape to chamfer the end of a cylinder.
// SynTags: Geom
// Topics: Masking, Chamfers, Cylinders
// See Also: chamfer_corner_mask(), chamfer_cylinder_mask(), chamfer_edge_mask()
// See Also: chamfer_corner_mask(), chamfer_cylinder_mask(), chamfer_edge_mask(), default_tag(), diff()
// Usage:
// chamfer_cylinder_mask(r|d=, chamfer, [ang], [from_end]) [ATTACHMENTS];
// Description:
@ -116,6 +124,8 @@ module chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) {
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example:
// difference() {
// cylinder(r=50, h=100, center=true);
@ -147,6 +157,7 @@ module chamfer_cylinder_mask(r, chamfer, d, ang=45, from_end=false, anchor=CENTE
r = get_radius(r=r, d=d, dflt=1);
dummy = assert(all_nonnegative([chamfer]), "Chamfer must be a nonnegative number");
ch = from_end? chamfer : opp_ang_to_adj(chamfer,90-ang);
default_tag("remove"){
attachable(anchor,spin,orient, r=r, l=ch*2) {
difference() {
cyl(r=r+chamfer, l=ch*2, anchor=CENTER);
@ -155,6 +166,7 @@ module chamfer_cylinder_mask(r, chamfer, d, ang=45, from_end=false, anchor=CENTE
children();
}
}
}
@ -164,7 +176,7 @@ module chamfer_cylinder_mask(r, chamfer, d, ang=45, from_end=false, anchor=CENTE
// Synopsis: Creates a shape to round a 90° edge.
// SynTags: Geom
// Topics: Masks, Rounding, Shapes (3D)
// See Also: rounding_angled_edge_mask(), rounding_corner_mask(), rounding_angled_corner_mask()
// See Also: rounding_angled_edge_mask(), rounding_corner_mask(), rounding_angled_corner_mask(), default_tag(), diff()
// Usage:
// rounding_edge_mask(l|h=|length=|height=, r|d=, [excess=]) [ATTACHMENTS];
// rounding_edge_mask(l|h=|length=|height=, r1=|d1=, r2=|d2=, [excess=]) [ATTACHMENTS];
@ -185,6 +197,8 @@ module chamfer_cylinder_mask(r, chamfer, d, ang=45, from_end=false, anchor=CENTE
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example(VPD=200,VPR=[55,0,120]):
// rounding_edge_mask(l=50, r1=10, r2=25);
// Example:
@ -217,6 +231,7 @@ module rounding_edge_mask(l, r, r1, r2, d, d1, d2, excess=0.1, anchor=CENTER, sp
r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=1);
r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=1);
sides = quantup(segs(max(r1,r2)),4);
default_tag("remove") {
attachable(anchor,spin,orient, size=[2*r1,2*r1,l], size2=[2*r2,2*r2]) {
if (r1<r2) {
zflip() {
@ -238,13 +253,14 @@ module rounding_edge_mask(l, r, r1, r2, d, d1, d2, excess=0.1, anchor=CENTER, sp
children();
}
}
}
// Module: rounding_corner_mask()
// Synopsis: Creates a shape to round 90° corners.
// SynTags: Geom
// Topics: Masking, Rounding, Shapes (3D)
// See Also: rounding_angled_corner_mask(), rounding_edge_mask(), rounding_angled_edge_mask()
// See Also: rounding_angled_corner_mask(), rounding_edge_mask(), rounding_angled_edge_mask(), default_tag(), diff()
// Usage:
// rounding_corner_mask(r|d, [excess=], [style=]) [ATTACHMENTS];
// Description:
@ -260,6 +276,8 @@ module rounding_edge_mask(l, r, r1, r2, d, d1, d2, excess=0.1, anchor=CENTER, sp
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example:
// rounding_corner_mask(r=20.0);
// Example:
@ -282,6 +300,7 @@ function rounding_corner_mask(r, d, style="octa", excess=0.1, anchor=CENTER, spi
module rounding_corner_mask(r, d, style="octa", excess=0.1, anchor=CENTER, spin=0, orient=UP)
{
r = get_radius(r=r, d=d, dflt=1);
default_tag("remove") {
attachable(anchor,spin,orient, size=[2,2,2]*r) {
difference() {
translate(-excess*[1,1,1])
@ -292,13 +311,14 @@ module rounding_corner_mask(r, d, style="octa", excess=0.1, anchor=CENTER, spin=
children();
}
}
}
// Module: rounding_angled_edge_mask()
// Synopsis: Creates a shape to round edges of any angle.
// SynTags: Geom
// Topics: Masks, Rounding
// See Also: rounding_angled_corner_mask(), rounding_edge_mask(), rounding_corner_mask()
// See Also: rounding_angled_corner_mask(), rounding_edge_mask(), rounding_corner_mask(), default_tag(), diff()
// Usage:
// rounding_angled_edge_mask(h|l=|length=|height=, r|d=, [ang=]) [ATTACHMENTS];
// rounding_angled_edge_mask(h|l=|length=|height=, r1=|d1=, r2=|d2=, [ang=]) [ATTACHMENTS];
@ -319,6 +339,8 @@ module rounding_corner_mask(r, d, style="octa", excess=0.1, anchor=CENTER, spin=
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example:
// difference() {
// pie_slice(ang=70, h=50, d=100, center=true);
@ -345,6 +367,7 @@ module rounding_angled_edge_mask(h, r, r1, r2, d, d1, d2, ang=90, anchor=CENTER,
n = ceil(segs(max(r1,r2))*sweep/360);
x = sin(90-(ang/2))/sin(ang/2) * (r1<r2? r2 : r1);
if(r1<r2) {
default_tag("remove") {
attachable(anchor,spin,orient, size=[2*x*r1/r2,2*r1,h], size2=[2*x,2*r2]) {
zflip() {
linear_extrude(height=h, convexity=4, center=true, scale=r1/r2) {
@ -353,7 +376,9 @@ module rounding_angled_edge_mask(h, r, r1, r2, d, d1, d2, ang=90, anchor=CENTER,
}
children();
}
}
} else {
default_tag("remove") {
attachable(anchor,spin,orient, size=[2*x,2*r1,h], size2=[2*x*r2/r1,2*r2]) {
linear_extrude(height=h, convexity=4, center=true, scale=r2/r1) {
polygon(_mask_shape(r1));
@ -362,13 +387,14 @@ module rounding_angled_edge_mask(h, r, r1, r2, d, d1, d2, ang=90, anchor=CENTER,
}
}
}
}
// Module: rounding_angled_corner_mask()
// Synopsis: Creates a shape to round the corner of an arbitrary angle.
// SynTags: Geom
// Topics: Masks, Rounding, Shapes (3D)
// See Also: rounding_angled_edge_mask(), rounding_corner_mask(), rounding_edge_mask()
// See Also: rounding_angled_edge_mask(), rounding_corner_mask(), rounding_edge_mask(), default_tag(), diff()
// Usage:
// rounding_angled_corner_mask(r|d=, [ang]) [ATTACHMENTS];
// Description:
@ -383,6 +409,8 @@ module rounding_angled_edge_mask(h, r, r1, r2, d, d1, d2, ang=90, anchor=CENTER,
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example(Med):
// ang=60;
// difference() {
@ -396,6 +424,7 @@ module rounding_angled_corner_mask(r, ang=90, d, anchor=CENTER, spin=0, orient=U
dx = r / tan(ang/2);
dx2 = dx / cos(ang/2) + 1;
fn = quantup(segs(r), 4);
default_tag("remove") {
attachable(anchor,spin,orient, d=dx2, l=2*r) {
difference() {
down(r) cylinder(r=dx2, h=r+1, center=false);
@ -414,13 +443,14 @@ module rounding_angled_corner_mask(r, ang=90, d, anchor=CENTER, spin=0, orient=U
children();
}
}
}
// Module: rounding_cylinder_mask()
// Synopsis: Creates a shape to round the end of a cylinder.
// SynTags: Geom
// Topics: Masking, Rounding, Cylinders
// See Also: rounding_hole_mask(), rounding_angled_edge_mask(), rounding_corner_mask(), rounding_angled_corner_mask()
// See Also: rounding_hole_mask(), rounding_angled_edge_mask(), rounding_corner_mask(), rounding_angled_corner_mask(), default_tag(), diff()
// Usage:
// rounding_cylinder_mask(r|d=, rounding);
// Description:
@ -436,6 +466,8 @@ module rounding_angled_corner_mask(r, ang=90, d, anchor=CENTER, spin=0, orient=U
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example:
// difference() {
// cylinder(r=50, h=50, center=false);
@ -457,6 +489,7 @@ function rounding_cylinder_mask(r, rounding, d, anchor, spin, orient) = no_funct
module rounding_cylinder_mask(r, rounding, d, anchor=CENTER, spin=0, orient=UP)
{
r = get_radius(r=r, d=d, dflt=1);
default_tag("remove") {
attachable(anchor,spin,orient, r=r+rounding, l=rounding*2) {
difference() {
cyl(r=r+rounding, l=rounding*2, anchor=CENTER);
@ -465,6 +498,7 @@ module rounding_cylinder_mask(r, rounding, d, anchor=CENTER, spin=0, orient=UP)
children();
}
}
}
@ -472,7 +506,7 @@ module rounding_cylinder_mask(r, rounding, d, anchor=CENTER, spin=0, orient=UP)
// Synopsis: Creates a shape to round the edge of a round hole.
// SynTags: Geom
// Topics: Masking, Rounding
// See Also: rounding_cylinder_mask(), rounding_hole_mask(), rounding_angled_edge_mask(), rounding_corner_mask(), rounding_angled_corner_mask()
// See Also: rounding_cylinder_mask(), rounding_hole_mask(), rounding_angled_edge_mask(), rounding_corner_mask(), rounding_angled_corner_mask(), default_tag(), diff()
// Usage:
// rounding_hole_mask(r|d, rounding, [excess]) [ATTACHMENTS];
// Description:
@ -489,6 +523,8 @@ module rounding_cylinder_mask(r, rounding, d, anchor=CENTER, spin=0, orient=UP)
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example:
// rounding_hole_mask(r=40, rounding=20, $fa=2, $fs=2);
// Example(Med):
@ -507,6 +543,7 @@ function rounding_hole_mask(r, rounding, excess=0.1, d, anchor=CENTER, spin=0, o
module rounding_hole_mask(r, rounding, excess=0.1, d, anchor=CENTER, spin=0, orient=UP)
{
r = get_radius(r=r, d=d, dflt=1);
default_tag("remove") {
attachable(anchor,spin,orient, r=r+rounding, l=2*rounding) {
rotate_extrude(convexity=4) {
difference() {
@ -517,6 +554,7 @@ module rounding_hole_mask(r, rounding, excess=0.1, d, anchor=CENTER, spin=0, ori
children();
}
}
}
// Section: Teardrop Masking
@ -525,7 +563,7 @@ module rounding_hole_mask(r, rounding, excess=0.1, d, anchor=CENTER, spin=0, ori
// Synopsis: Creates a shape to round a 90° edge but limit the angle of overhang.
// SynTags: Geom
// Topics: Masking, Rounding, Shapes (3D), FDM Optimized
// See Also: teardrop_corner_mask(), teardrop_edge_mask()
// See Also: teardrop_corner_mask(), teardrop_edge_mask(), default_tag(), diff()
// Usage:
// teardrop_edge_mask(l|h=|length=|height=, r|d=, [angle], [excess], [anchor], [spin], [orient]) [ATTACHMENTS];
// Description:
@ -540,6 +578,8 @@ module rounding_hole_mask(r, rounding, excess=0.1, d, anchor=CENTER, spin=0, ori
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example(VPD=50,VPR=[55,0,120]):
// teardrop_edge_mask(l=20, r=10, angle=40);
// Example(VPD=300,VPR=[75,0,25]):
@ -560,15 +600,17 @@ module teardrop_edge_mask(l, r, angle=45, excess=0.1, d, anchor=CTR, spin=0, ori
assert(is_num(excess));
r = get_radius(r=r, d=d, dflt=1);
path = mask2d_teardrop(r=r, angle=angle, excess=excess);
default_tag("remove") {
linear_sweep(path, height=l, center=true, atype="bbox", anchor=anchor, spin=spin, orient=orient) children();
}
}
// Module: teardrop_corner_mask()
// Synopsis: Creates a shape to round a 90° corner but limit the angle of overhang.
// SynTags: Geom
// Topics: Masking, Rounding, Shapes (3D), FDM Optimized
// See Also: teardrop_corner_mask(), teardrop_edge_mask()
// See Also: teardrop_corner_mask(), teardrop_edge_mask(), default_tag(), diff()
// Usage:
// teardrop_corner_mask(r|d=, [angle], [excess], [anchor], [spin], [orient]) [ATTACHMENTS];
// Description:
@ -582,6 +624,8 @@ module teardrop_edge_mask(l, r, angle=45, excess=0.1, d, anchor=CTR, spin=0, ori
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// Side Effects:
// Tags the children with "remove" (and hence sets `$tag`) if no tag is already set.
// Example:
// teardrop_corner_mask(r=20, angle=40);
// Example:
@ -601,6 +645,7 @@ module teardrop_corner_mask(r, angle=45, excess=0.1, d, anchor=CTR, spin=0, orie
r = get_radius(r=r, d=d, dflt=1);
size = (r+excess) * [1,1,1];
midpt = (r-excess)/2 * [1,1,1];
default_tag("remove") {
attachable(anchor,spin,orient, size=size, offset=midpt) {
difference() {
translate(-[1,1,1]*excess) cube(r+excess, center=false);
@ -609,6 +654,7 @@ module teardrop_corner_mask(r, angle=45, excess=0.1, d, anchor=CTR, spin=0, orie
children();
}
}
}