diff --git a/attachments.scad b/attachments.scad index 9e797b87..3657741c 100644 --- a/attachments.scad +++ b/attachments.scad @@ -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,21 +2190,22 @@ 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; - translate(anch[1]) { - rot(rotang) { - down(0.01) { - linear_extrude(height=r+0.01, center=false) { - difference() { - translate(-[0.01,0.01]) square(r); - translate([r,r]) circle(r=r*0.999); + default_tag("remove"){ + translate(anch[1]) { + rot(rotang) { + down(0.01) { + linear_extrude(height=r+0.01, center=false) { + difference() { + translate(-[0.01,0.01]) square(r); + translate([r,r]) circle(r=r*0.999); + } } } - } - translate([r,r]) zrot(180) { - rotate_extrude(angle=90, convexity=convexity) { - right(r) xflip() { - children(); + translate([r,r]) zrot(180) { + rotate_extrude(angle=90, convexity=convexity) { + right(r) xflip() { + children(); + } } } } diff --git a/masks2d.scad b/masks2d.scad index 96c2aea5..81071a6f 100644 --- a/masks2d.scad +++ b/masks2d.scad @@ -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,9 +63,11 @@ // 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); - attachable(anchor,spin, two_d=true, path=path) { - polygon(path); - children(); + default_tag("remove") { + attachable(anchor,spin, two_d=true, path=path) { + 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. // 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,9 +144,11 @@ 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); - attachable(anchor,spin, two_d=true, path=path) { - polygon(path); - children(); + default_tag("remove") { + attachable(anchor,spin, two_d=true, path=path) { + 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. // 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,9 +232,11 @@ 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); - attachable(anchor,spin, two_d=true, path=path, extent=true) { - polygon(path); - children(); + default_tag("remove") { + attachable(anchor,spin, two_d=true, path=path, extent=true) { + 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` // 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,9 +305,11 @@ 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); - attachable(anchor,spin, two_d=true, path=path, extent=false) { - polygon(path); - children(); + default_tag("remove") { + attachable(anchor,spin, two_d=true, path=path, extent=false) { + 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. // 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,9 +386,11 @@ 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); - attachable(anchor,spin, two_d=true, path=path) { - polygon(path); - children(); + default_tag("remove") { + attachable(anchor,spin, two_d=true, path=path) { + 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. // 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,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) { path = mask2d_teardrop(r=r, d=d, angle=angle, mask_angle=mask_angle, excess=excess); - attachable(anchor,spin, two_d=true, path=path) { - polygon(path); - children(); + default_tag("remove") { + attachable(anchor,spin, two_d=true, path=path) { + 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` // 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,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) { path = mask2d_ogee(pattern, excess=excess); - attachable(anchor,spin, two_d=true, path=path) { - polygon(path); - children(); + default_tag("remove") { + attachable(anchor,spin, two_d=true, path=path) { + polygon(path); + children(); + } } } diff --git a/masks3d.scad b/masks3d.scad index 4e479e42..622a4a19 100644 --- a/masks3d.scad +++ b/masks3d.scad @@ -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,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"); 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"); - attachable(anchor,spin,orient, size=[chamfer*2, chamfer*2, l]) { - cylinder(r=chamfer, h=l+excess, center=true, $fn=4); - children(); + default_tag("remove") { + attachable(anchor,spin,orient, size=[chamfer*2, chamfer*2, l]) { + 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. // 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,7 +96,9 @@ 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) { - 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. // 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,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); dummy = assert(all_nonnegative([chamfer]), "Chamfer must be a nonnegative number"); ch = from_end? chamfer : opp_ang_to_adj(chamfer,90-ang); - attachable(anchor,spin,orient, r=r, l=ch*2) { - difference() { - 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); + default_tag("remove"){ + attachable(anchor,spin,orient, r=r, l=ch*2) { + difference() { + 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. // 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,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); r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=1); sides = quantup(segs(max(r1,r2)),4); - attachable(anchor,spin,orient, size=[2*r1,2*r1,l], size2=[2*r2,2*r2]) { - if (r1