Merge pull request #1282 from RAMilewski/master

Add default_tag(remove) to masks*d.scad
This commit is contained in:
Revar Desmera 2023-10-03 23:59:17 -07:00 committed by GitHub
commit 2f5bf86f92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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(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!"); assert($parent_geom != undef, "No object to attach to!");
attach(faces) { attach(faces) {
if ($tag=="") tag("remove") children(); default_tag("remove") children();
else 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. // except = Edges to explicitly NOT mask. See [Specifying Edges](attachments.scad#subsection-specifying-edges). Default: No edges.
// Side Effects: // 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.
// 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. // `$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. // `$attach_anchor` is set for each edge given, to the `[ANCHOR, POSITION, ORIENT, SPIN]` information for that anchor.
// Example: // 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)] : vec.z==0 && sign(vec.x)!=sign(vec.y)? [0,180,45+v_theta(vec)] :
[-90,0,180+v_theta(vec)]; [-90,0,180+v_theta(vec)];
translate(anch[1]) rot(rotang) translate(anch[1]) rot(rotang)
if ($tag=="") tag("remove") children(); default_tag("remove") children();
else children();
} }
} }
@ -1659,8 +1655,7 @@ module corner_mask(corners=CORNERS_ALL, except=[]) {
[ 0,0,180+v_theta(vec)-45] : [ 0,0,180+v_theta(vec)-45] :
[180,0,-90+v_theta(vec)-45]; [180,0,-90+v_theta(vec)-45];
translate(anch[1]) rot(rotang) translate(anch[1]) rot(rotang)
if ($tag=="") tag("remove") children(); default_tag("remove") children();
else children();
} }
} }
@ -2167,7 +2162,7 @@ module edge_profile_asym(
// d = Diameter of corner mask. // d = Diameter of corner mask.
// convexity = Max number of times a line could intersect the perimeter of the mask shape. Default: 10 // convexity = Max number of times a line could intersect the perimeter of the mask shape. Default: 10
// Side Effects: // 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. // `$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. // `$attach_anchor` is set for each corner given, to the `[ANCHOR, POSITION, ORIENT, SPIN]` information for that anchor.
// `$profile_type` is set to `"corner"`. // `$profile_type` is set to `"corner"`.
@ -2195,21 +2190,22 @@ module corner_profile(corners=CORNERS_ALL, except=[], r, d, convexity=10) {
rotang = vec.z<0? rotang = vec.z<0?
[ 0,0,180+v_theta(vec)-45] : [ 0,0,180+v_theta(vec)-45] :
[180,0,-90+v_theta(vec)-45]; [180,0,-90+v_theta(vec)-45];
$tag = $tag=="" ? str($tag_prefix,"remove") : $tag; default_tag("remove"){
translate(anch[1]) { translate(anch[1]) {
rot(rotang) { rot(rotang) {
down(0.01) { down(0.01) {
linear_extrude(height=r+0.01, center=false) { linear_extrude(height=r+0.01, center=false) {
difference() { difference() {
translate(-[0.01,0.01]) square(r); translate(-[0.01,0.01]) square(r);
translate([r,r]) circle(r=r*0.999); translate([r,r]) circle(r=r*0.999);
}
} }
} }
} translate([r,r]) zrot(180) {
translate([r,r]) zrot(180) { rotate_extrude(angle=90, convexity=convexity) {
rotate_extrude(angle=90, convexity=convexity) { right(r) xflip() {
right(r) xflip() { children();
children(); }
} }
} }
} }

View file

@ -37,6 +37,9 @@
// d = Diameter of the roundover. // d = Diameter of the roundover.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `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` // 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 // Example(2D): 2D Roundover Mask
// mask2d_roundover(r=10); // mask2d_roundover(r=10);
// Example(2D): 2D Bead Mask // Example(2D): 2D Bead Mask
@ -60,9 +63,11 @@
// mask2d_roundover(r=10); // mask2d_roundover(r=10);
module mask2d_roundover(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENTER,spin=0) { 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); path = mask2d_roundover(r=r, d=d, inset=inset, mask_angle=mask_angle, excess=excess);
attachable(anchor,spin, two_d=true, path=path) { default_tag("remove") {
polygon(path); attachable(anchor,spin, two_d=true, path=path) {
children(); polygon(path);
children();
}
} }
} }
@ -114,6 +119,8 @@ function mask2d_roundover(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENT
// d = Diameter of the cove. // d = Diameter of the cove.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `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` // 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 // Example(2D): 2D Cove Mask
// mask2d_cove(r=10); // mask2d_cove(r=10);
// Example(2D): 2D Inset Cove Mask // Example(2D): 2D Inset Cove Mask
@ -137,9 +144,11 @@ function mask2d_roundover(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENT
// mask2d_cove(r=5, inset=5); // mask2d_cove(r=5, inset=5);
module mask2d_cove(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENTER, spin=0) { 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); path = mask2d_cove(r=r, d=d, inset=inset, mask_angle=mask_angle, excess=excess);
attachable(anchor,spin, two_d=true, path=path) { default_tag("remove") {
polygon(path); attachable(anchor,spin, two_d=true, path=path) {
children(); polygon(path);
children();
}
} }
} }
@ -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. // 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` // 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` // 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 // Example(2D): 2D Chamfer Mask
// mask2d_chamfer(x=10); // mask2d_chamfer(x=10);
// Example(2D): 2D Chamfer Mask by Width. // Example(2D): 2D Chamfer Mask by Width.
@ -221,9 +232,11 @@ function mask2d_cove(r, inset=0, mask_angle=90, excess=0.01, d, anchor=CENTER, s
// mask2d_chamfer(edge=10); // mask2d_chamfer(edge=10);
module mask2d_chamfer(edge, angle=45, inset=0, excess=0.01, x, y, anchor=CENTER,spin=0) { 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); path = mask2d_chamfer(x=x, y=y, edge=edge, angle=angle, excess=excess, inset=inset);
attachable(anchor,spin, two_d=true, path=path, extent=true) { default_tag("remove") {
polygon(path); attachable(anchor,spin, two_d=true, path=path, extent=true) {
children(); polygon(path);
children();
}
} }
} }
@ -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` // 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` // 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 // Example(2D): 2D Rabbet Mask
// mask2d_rabbet(size=10); // mask2d_rabbet(size=10);
// Example(2D): 2D Asymmetrical Rabbet Mask // Example(2D): 2D Asymmetrical Rabbet Mask
@ -290,9 +305,11 @@ function mask2d_chamfer(edge, angle=45, inset=0, excess=0.01, x, y, anchor=CENTE
// mask2d_rabbet(size=[5,10]); // mask2d_rabbet(size=[5,10]);
module mask2d_rabbet(size, mask_angle=90, excess=0.01, anchor=CTR, spin=0) { 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); path = mask2d_rabbet(size=size, mask_angle=mask_angle, excess=excess);
attachable(anchor,spin, two_d=true, path=path, extent=false) { default_tag("remove") {
polygon(path); attachable(anchor,spin, two_d=true, path=path, extent=false) {
children(); polygon(path);
children();
}
} }
} }
@ -344,6 +361,8 @@ function mask2d_rabbet(size, mask_angle=90, excess=0.01, anchor=CTR, spin=0) =
// y = The height of the dovetail. // 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` // 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` // 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 // Example(2D): 2D Dovetail Mask
// mask2d_dovetail(x=10); // mask2d_dovetail(x=10);
// Example(2D): 2D Dovetail Mask by Width. // Example(2D): 2D Dovetail Mask by Width.
@ -367,9 +386,11 @@ function mask2d_rabbet(size, mask_angle=90, excess=0.01, anchor=CTR, spin=0) =
// mask2d_dovetail(x=10); // mask2d_dovetail(x=10);
module mask2d_dovetail(edge, angle=30, inset=0, shelf=0, excess=0.01, x, y, anchor=CENTER, spin=0) { 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); path = mask2d_dovetail(x=x, y=y, edge=edge, angle=angle, inset=inset, shelf=shelf, excess=excess);
attachable(anchor,spin, two_d=true, path=path) { default_tag("remove") {
polygon(path); attachable(anchor,spin, two_d=true, path=path) {
children(); polygon(path);
children();
}
} }
} }
@ -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. // d = Diameter of the rounding.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `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` // 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 // Example(2D): 2D Teardrop Mask
// mask2d_teardrop(r=10); // mask2d_teardrop(r=10);
// Example(2D): 2D Teardrop Mask for a Non-Right Edge // Example(2D): 2D Teardrop Mask for a Non-Right Edge
@ -469,9 +492,11 @@ 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) { 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); path = mask2d_teardrop(r=r, d=d, angle=angle, mask_angle=mask_angle, excess=excess);
attachable(anchor,spin, two_d=true, path=path) { default_tag("remove") {
polygon(path); attachable(anchor,spin, two_d=true, path=path) {
children(); polygon(path);
children();
}
} }
} }
@ -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` // 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` // 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 // Example(2D): 2D Ogee Mask
// mask2d_ogee([ // mask2d_ogee([
// "xstep",1, "ystep",1, // Starting shoulder. // "xstep",1, "ystep",1, // Starting shoulder.
@ -539,9 +567,11 @@ 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) { module mask2d_ogee(pattern, excess=0.01, anchor=CENTER,spin=0) {
path = mask2d_ogee(pattern, excess=excess); path = mask2d_ogee(pattern, excess=excess);
attachable(anchor,spin, two_d=true, path=path) { default_tag("remove") {
polygon(path); attachable(anchor,spin, two_d=true, path=path) {
children(); polygon(path);
children();
}
} }
} }

View file

@ -17,7 +17,7 @@
// Synopsis: Creates a shape to chamfer a 90° edge. // Synopsis: Creates a shape to chamfer a 90° edge.
// SynTags: Geom // SynTags: Geom
// Topics: Masking, Chamfers, Shapes (3D) // 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: // Usage:
// chamfer_edge_mask(l|h=|length=|height=, chamfer, [excess]) [ATTACHMENTS]; // chamfer_edge_mask(l|h=|length=|height=, chamfer, [excess]) [ATTACHMENTS];
// Description: // Description:
@ -32,6 +32,8 @@
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `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` // 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` // 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: // Example:
// chamfer_edge_mask(l=50, chamfer=10); // chamfer_edge_mask(l=50, chamfer=10);
// Example: // Example:
@ -48,9 +50,11 @@
function chamfer_edge_mask(l, chamfer=1, excess=0.1, h, length, height, anchor=CENTER, spin=0, orient=UP) = no_function("chamfer_edge_mask"); 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) { 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"); l = one_defined([l, h, height, length], "l,h,height,length");
attachable(anchor,spin,orient, size=[chamfer*2, chamfer*2, l]) { default_tag("remove") {
cylinder(r=chamfer, h=l+excess, center=true, $fn=4); attachable(anchor,spin,orient, size=[chamfer*2, chamfer*2, l]) {
children(); cylinder(r=chamfer, h=l+excess, center=true, $fn=4);
children();
}
} }
} }
@ -59,7 +63,7 @@ module chamfer_edge_mask(l, chamfer=1, excess=0.1, h, length, height, anchor=CEN
// Synopsis: Creates a shape to chamfer a 90° corner. // Synopsis: Creates a shape to chamfer a 90° corner.
// SynTags: Geom // SynTags: Geom
// Topics: Masking, Chamfers, Shapes (3D) // 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: // Usage:
// chamfer_corner_mask(chamfer) [ATTACHMENTS]; // chamfer_corner_mask(chamfer) [ATTACHMENTS];
// Description: // 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` // 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` // 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` // 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: // Example:
// chamfer_corner_mask(chamfer=10); // chamfer_corner_mask(chamfer=10);
// Example: // Example:
@ -90,7 +96,9 @@ module chamfer_edge_mask(l, chamfer=1, excess=0.1, h, length, height, anchor=CEN
// show_anchors(); // show_anchors();
function chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) = no_function("chamfer_corner_mask"); 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) { module chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) {
octahedron(chamfer*4, anchor=anchor, spin=spin, orient=orient) children(); default_tag("remove") {
octahedron(chamfer*4, anchor=anchor, spin=spin, orient=orient) children();
}
} }
@ -98,7 +106,7 @@ module chamfer_corner_mask(chamfer=1, anchor=CENTER, spin=0, orient=UP) {
// Synopsis: Creates a shape to chamfer the end of a cylinder. // Synopsis: Creates a shape to chamfer the end of a cylinder.
// SynTags: Geom // SynTags: Geom
// Topics: Masking, Chamfers, Cylinders // 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: // Usage:
// chamfer_cylinder_mask(r|d=, chamfer, [ang], [from_end]) [ATTACHMENTS]; // chamfer_cylinder_mask(r|d=, chamfer, [ang], [from_end]) [ATTACHMENTS];
// Description: // 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` // 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` // 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` // 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: // Example:
// difference() { // difference() {
// cylinder(r=50, h=100, center=true); // cylinder(r=50, h=100, center=true);
@ -147,12 +157,14 @@ module chamfer_cylinder_mask(r, chamfer, d, ang=45, from_end=false, anchor=CENTE
r = get_radius(r=r, d=d, dflt=1); r = get_radius(r=r, d=d, dflt=1);
dummy = assert(all_nonnegative([chamfer]), "Chamfer must be a nonnegative number"); dummy = assert(all_nonnegative([chamfer]), "Chamfer must be a nonnegative number");
ch = from_end? chamfer : opp_ang_to_adj(chamfer,90-ang); ch = from_end? chamfer : opp_ang_to_adj(chamfer,90-ang);
attachable(anchor,spin,orient, r=r, l=ch*2) { default_tag("remove"){
difference() { attachable(anchor,spin,orient, r=r, l=ch*2) {
cyl(r=r+chamfer, l=ch*2, anchor=CENTER); difference() {
cyl(r=r, l=ch*3, chamfer=chamfer, chamfang=ang, from_end=from_end, anchor=TOP); cyl(r=r+chamfer, l=ch*2, anchor=CENTER);
cyl(r=r, l=ch*3, chamfer=chamfer, chamfang=ang, from_end=from_end, anchor=TOP);
}
children();
} }
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. // Synopsis: Creates a shape to round a 90° edge.
// SynTags: Geom // SynTags: Geom
// Topics: Masks, Rounding, Shapes (3D) // 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: // Usage:
// rounding_edge_mask(l|h=|length=|height=, r|d=, [excess=]) [ATTACHMENTS]; // rounding_edge_mask(l|h=|length=|height=, r|d=, [excess=]) [ATTACHMENTS];
// rounding_edge_mask(l|h=|length=|height=, r1=|d1=, r2=|d2=, [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` // 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` // 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` // 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]): // Example(VPD=200,VPR=[55,0,120]):
// rounding_edge_mask(l=50, r1=10, r2=25); // rounding_edge_mask(l=50, r1=10, r2=25);
// Example: // Example:
@ -217,25 +231,27 @@ 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); 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); r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=1);
sides = quantup(segs(max(r1,r2)),4); sides = quantup(segs(max(r1,r2)),4);
attachable(anchor,spin,orient, size=[2*r1,2*r1,l], size2=[2*r2,2*r2]) { default_tag("remove") {
if (r1<r2) { attachable(anchor,spin,orient, size=[2*r1,2*r1,l], size2=[2*r2,2*r2]) {
zflip() { if (r1<r2) {
linear_extrude(height=l, convexity=4, center=true, scale=r1/r2) { zflip() {
linear_extrude(height=l, convexity=4, center=true, scale=r1/r2) {
difference() {
translate(-excess*[1,1]) square(r2+excess);
translate([r2,r2]) circle(r=r2, $fn=sides);
}
}
}
} else {
linear_extrude(height=l, convexity=4, center=true, scale=r2/r1) {
difference() { difference() {
translate(-excess*[1,1]) square(r2+excess); translate(-excess*[1,1]) square(r1+excess);
translate([r2,r2]) circle(r=r2, $fn=sides); translate([r1,r1]) circle(r=r1, $fn=sides);
} }
} }
} }
} else { children();
linear_extrude(height=l, convexity=4, center=true, scale=r2/r1) {
difference() {
translate(-excess*[1,1]) square(r1+excess);
translate([r1,r1]) circle(r=r1, $fn=sides);
}
}
} }
children();
} }
} }
@ -244,7 +260,7 @@ module rounding_edge_mask(l, r, r1, r2, d, d1, d2, excess=0.1, anchor=CENTER, sp
// Synopsis: Creates a shape to round 90° corners. // Synopsis: Creates a shape to round 90° corners.
// SynTags: Geom // SynTags: Geom
// Topics: Masking, Rounding, Shapes (3D) // 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: // Usage:
// rounding_corner_mask(r|d, [excess=], [style=]) [ATTACHMENTS]; // rounding_corner_mask(r|d, [excess=], [style=]) [ATTACHMENTS];
// Description: // 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` // 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` // 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` // 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: // Example:
// rounding_corner_mask(r=20.0); // rounding_corner_mask(r=20.0);
// Example: // Example:
@ -282,14 +300,16 @@ 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) 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); r = get_radius(r=r, d=d, dflt=1);
attachable(anchor,spin,orient, size=[2,2,2]*r) { default_tag("remove") {
difference() { attachable(anchor,spin,orient, size=[2,2,2]*r) {
translate(-excess*[1,1,1]) difference() {
cube(size=r+excess, center=false); translate(-excess*[1,1,1])
translate([r,r,r]) cube(size=r+excess, center=false);
spheroid(r=r, style=style); translate([r,r,r])
spheroid(r=r, style=style);
}
children();
} }
children();
} }
} }
@ -298,7 +318,7 @@ module rounding_corner_mask(r, d, style="octa", excess=0.1, anchor=CENTER, spin=
// Synopsis: Creates a shape to round edges of any angle. // Synopsis: Creates a shape to round edges of any angle.
// SynTags: Geom // SynTags: Geom
// Topics: Masks, Rounding // 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: // Usage:
// rounding_angled_edge_mask(h|l=|length=|height=, r|d=, [ang=]) [ATTACHMENTS]; // 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]; // 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` // 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` // 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` // 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: // Example:
// difference() { // difference() {
// pie_slice(ang=70, h=50, d=100, center=true); // pie_slice(ang=70, h=50, d=100, center=true);
@ -345,20 +367,24 @@ module rounding_angled_edge_mask(h, r, r1, r2, d, d1, d2, ang=90, anchor=CENTER,
n = ceil(segs(max(r1,r2))*sweep/360); n = ceil(segs(max(r1,r2))*sweep/360);
x = sin(90-(ang/2))/sin(ang/2) * (r1<r2? r2 : r1); x = sin(90-(ang/2))/sin(ang/2) * (r1<r2? r2 : r1);
if(r1<r2) { if(r1<r2) {
attachable(anchor,spin,orient, size=[2*x*r1/r2,2*r1,h], size2=[2*x,2*r2]) { default_tag("remove") {
zflip() { attachable(anchor,spin,orient, size=[2*x*r1/r2,2*r1,h], size2=[2*x,2*r2]) {
linear_extrude(height=h, convexity=4, center=true, scale=r1/r2) { zflip() {
polygon(_mask_shape(r2)); linear_extrude(height=h, convexity=4, center=true, scale=r1/r2) {
polygon(_mask_shape(r2));
}
} }
children();
} }
children();
} }
} else { } else {
attachable(anchor,spin,orient, size=[2*x,2*r1,h], size2=[2*x*r2/r1,2*r2]) { default_tag("remove") {
linear_extrude(height=h, convexity=4, center=true, scale=r2/r1) { attachable(anchor,spin,orient, size=[2*x,2*r1,h], size2=[2*x*r2/r1,2*r2]) {
polygon(_mask_shape(r1)); linear_extrude(height=h, convexity=4, center=true, scale=r2/r1) {
polygon(_mask_shape(r1));
}
children();
} }
children();
} }
} }
} }
@ -368,7 +394,7 @@ module rounding_angled_edge_mask(h, r, r1, r2, d, d1, d2, ang=90, anchor=CENTER,
// Synopsis: Creates a shape to round the corner of an arbitrary angle. // Synopsis: Creates a shape to round the corner of an arbitrary angle.
// SynTags: Geom // SynTags: Geom
// Topics: Masks, Rounding, Shapes (3D) // 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: // Usage:
// rounding_angled_corner_mask(r|d=, [ang]) [ATTACHMENTS]; // rounding_angled_corner_mask(r|d=, [ang]) [ATTACHMENTS];
// Description: // 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` // 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` // 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` // 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): // Example(Med):
// ang=60; // ang=60;
// difference() { // difference() {
@ -396,22 +424,24 @@ module rounding_angled_corner_mask(r, ang=90, d, anchor=CENTER, spin=0, orient=U
dx = r / tan(ang/2); dx = r / tan(ang/2);
dx2 = dx / cos(ang/2) + 1; dx2 = dx / cos(ang/2) + 1;
fn = quantup(segs(r), 4); fn = quantup(segs(r), 4);
attachable(anchor,spin,orient, d=dx2, l=2*r) { default_tag("remove") {
difference() { attachable(anchor,spin,orient, d=dx2, l=2*r) {
down(r) cylinder(r=dx2, h=r+1, center=false); difference() {
yflip_copy() { down(r) cylinder(r=dx2, h=r+1, center=false);
translate([dx, r, -r]) { yflip_copy() {
hull() { translate([dx, r, -r]) {
sphere(r=r, $fn=fn); hull() {
down(r*3) sphere(r=r, $fn=fn); sphere(r=r, $fn=fn);
zrot_copies([0,ang]) { down(r*3) sphere(r=r, $fn=fn);
right(r*3) sphere(r=r, $fn=fn); zrot_copies([0,ang]) {
right(r*3) sphere(r=r, $fn=fn);
}
} }
} }
} }
} }
children();
} }
children();
} }
} }
@ -420,7 +450,7 @@ module rounding_angled_corner_mask(r, ang=90, d, anchor=CENTER, spin=0, orient=U
// Synopsis: Creates a shape to round the end of a cylinder. // Synopsis: Creates a shape to round the end of a cylinder.
// SynTags: Geom // SynTags: Geom
// Topics: Masking, Rounding, Cylinders // 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: // Usage:
// rounding_cylinder_mask(r|d=, rounding); // rounding_cylinder_mask(r|d=, rounding);
// Description: // 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` // 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` // 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` // 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: // Example:
// difference() { // difference() {
// cylinder(r=50, h=50, center=false); // cylinder(r=50, h=50, center=false);
@ -457,12 +489,14 @@ 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) module rounding_cylinder_mask(r, rounding, d, anchor=CENTER, spin=0, orient=UP)
{ {
r = get_radius(r=r, d=d, dflt=1); r = get_radius(r=r, d=d, dflt=1);
attachable(anchor,spin,orient, r=r+rounding, l=rounding*2) { default_tag("remove") {
difference() { attachable(anchor,spin,orient, r=r+rounding, l=rounding*2) {
cyl(r=r+rounding, l=rounding*2, anchor=CENTER); difference() {
cyl(r=r, l=rounding*3, rounding=rounding, anchor=TOP); cyl(r=r+rounding, l=rounding*2, anchor=CENTER);
cyl(r=r, l=rounding*3, rounding=rounding, anchor=TOP);
}
children();
} }
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. // Synopsis: Creates a shape to round the edge of a round hole.
// SynTags: Geom // SynTags: Geom
// Topics: Masking, Rounding // 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: // Usage:
// rounding_hole_mask(r|d, rounding, [excess]) [ATTACHMENTS]; // rounding_hole_mask(r|d, rounding, [excess]) [ATTACHMENTS];
// Description: // 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` // 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` // 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` // 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: // Example:
// rounding_hole_mask(r=40, rounding=20, $fa=2, $fs=2); // rounding_hole_mask(r=40, rounding=20, $fa=2, $fs=2);
// Example(Med): // Example(Med):
@ -507,14 +543,16 @@ 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) 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); r = get_radius(r=r, d=d, dflt=1);
attachable(anchor,spin,orient, r=r+rounding, l=2*rounding) { default_tag("remove") {
rotate_extrude(convexity=4) { attachable(anchor,spin,orient, r=r+rounding, l=2*rounding) {
difference() { rotate_extrude(convexity=4) {
right(r-excess) fwd(rounding) square(rounding+excess, center=false); difference() {
right(r+rounding) fwd(rounding) circle(r=rounding); right(r-excess) fwd(rounding) square(rounding+excess, center=false);
right(r+rounding) fwd(rounding) circle(r=rounding);
}
} }
children();
} }
children();
} }
} }
@ -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. // Synopsis: Creates a shape to round a 90° edge but limit the angle of overhang.
// SynTags: Geom // SynTags: Geom
// Topics: Masking, Rounding, Shapes (3D), FDM Optimized // 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: // Usage:
// teardrop_edge_mask(l|h=|length=|height=, r|d=, [angle], [excess], [anchor], [spin], [orient]) [ATTACHMENTS]; // teardrop_edge_mask(l|h=|length=|height=, r|d=, [angle], [excess], [anchor], [spin], [orient]) [ATTACHMENTS];
// Description: // 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` // 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` // 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` // 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]): // Example(VPD=50,VPR=[55,0,120]):
// teardrop_edge_mask(l=20, r=10, angle=40); // teardrop_edge_mask(l=20, r=10, angle=40);
// Example(VPD=300,VPR=[75,0,25]): // Example(VPD=300,VPR=[75,0,25]):
@ -560,7 +600,9 @@ module teardrop_edge_mask(l, r, angle=45, excess=0.1, d, anchor=CTR, spin=0, ori
assert(is_num(excess)); assert(is_num(excess));
r = get_radius(r=r, d=d, dflt=1); r = get_radius(r=r, d=d, dflt=1);
path = mask2d_teardrop(r=r, angle=angle, excess=excess); path = mask2d_teardrop(r=r, angle=angle, excess=excess);
linear_sweep(path, height=l, center=true, atype="bbox", anchor=anchor, spin=spin, orient=orient) children(); default_tag("remove") {
linear_sweep(path, height=l, center=true, atype="bbox", anchor=anchor, spin=spin, orient=orient) children();
}
} }
@ -568,7 +610,7 @@ module teardrop_edge_mask(l, r, angle=45, excess=0.1, d, anchor=CTR, spin=0, ori
// Synopsis: Creates a shape to round a 90° corner but limit the angle of overhang. // Synopsis: Creates a shape to round a 90° corner but limit the angle of overhang.
// SynTags: Geom // SynTags: Geom
// Topics: Masking, Rounding, Shapes (3D), FDM Optimized // 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: // Usage:
// teardrop_corner_mask(r|d=, [angle], [excess], [anchor], [spin], [orient]) [ATTACHMENTS]; // teardrop_corner_mask(r|d=, [angle], [excess], [anchor], [spin], [orient]) [ATTACHMENTS];
// Description: // 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` // 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` // 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` // 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: // Example:
// teardrop_corner_mask(r=20, angle=40); // teardrop_corner_mask(r=20, angle=40);
// Example: // Example:
@ -601,12 +645,14 @@ 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); r = get_radius(r=r, d=d, dflt=1);
size = (r+excess) * [1,1,1]; size = (r+excess) * [1,1,1];
midpt = (r-excess)/2 * [1,1,1]; midpt = (r-excess)/2 * [1,1,1];
attachable(anchor,spin,orient, size=size, offset=midpt) { default_tag("remove") {
difference() { attachable(anchor,spin,orient, size=size, offset=midpt) {
translate(-[1,1,1]*excess) cube(r+excess, center=false); difference() {
translate([1,1,1]*r) onion(r=r, ang=angle, orient=DOWN); translate(-[1,1,1]*excess) cube(r+excess, center=false);
translate([1,1,1]*r) onion(r=r, ang=angle, orient=DOWN);
}
children();
} }
children();
} }
} }