mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-17 09:59:39 +00:00
Renamed exterior fillets to rounding
This commit is contained in:
parent
eed35ad9b4
commit
42d1a45ca6
5 changed files with 188 additions and 187 deletions
243
masks.scad
243
masks.scad
|
@ -78,19 +78,20 @@ module angle_pie_mask(
|
||||||
// Module: cylinder_mask()
|
// Module: cylinder_mask()
|
||||||
// Usage: Mask objects
|
// Usage: Mask objects
|
||||||
// cylinder_mask(l, r|d, chamfer, [chamfang], [from_end], [circum], [overage], [ends_only], [orient], [anchor]);
|
// cylinder_mask(l, r|d, chamfer, [chamfang], [from_end], [circum], [overage], [ends_only], [orient], [anchor]);
|
||||||
// cylinder_mask(l, r|d, fillet, [circum], [overage], [ends_only], [orient], [anchor]);
|
// cylinder_mask(l, r|d, rounding, [circum], [overage], [ends_only], [orient], [anchor]);
|
||||||
// cylinder_mask(l, r|d, [chamfer1|fillet1], [chamfer2|fillet2], [chamfang1], [chamfang2], [from_end], [circum], [overage], [ends_only], [orient], [anchor]);
|
// cylinder_mask(l, r|d, [chamfer1|rounding1], [chamfer2|rounding2], [chamfang1], [chamfang2], [from_end], [circum], [overage], [ends_only], [orient], [anchor]);
|
||||||
// Usage: Masking operators
|
// Usage: Masking operators
|
||||||
// cylinder_mask(l, r|d, chamfer, [chamfang], [from_end], [circum], [overage], [ends_only], [orient], [anchor]) ...
|
// cylinder_mask(l, r|d, chamfer, [chamfang], [from_end], [circum], [overage], [ends_only], [orient], [anchor]) ...
|
||||||
// cylinder_mask(l, r|d, fillet, [circum], [overage], [ends_only], [orient], [anchor]) ...
|
// cylinder_mask(l, r|d, rounding, [circum], [overage], [ends_only], [orient], [anchor]) ...
|
||||||
// cylinder_mask(l, r|d, [chamfer1|fillet1], [chamfer2|fillet2], [chamfang1], [chamfang2], [from_end], [circum], [overage], [ends_only], [orient], [anchor]) ...
|
// cylinder_mask(l, r|d, [chamfer1|rounding1], [chamfer2|rounding2], [chamfang1], [chamfang2], [from_end], [circum], [overage], [ends_only], [orient], [anchor]) ...
|
||||||
// Description:
|
// Description:
|
||||||
// If passed children, bevels/chamfers and/or rounds/fillets one or
|
// If passed children, bevels/chamfers and/or rounds one or both
|
||||||
// both ends of the origin-centered cylindrical region specified. If
|
// ends of the origin-centered cylindrical region specified. If
|
||||||
// passed no children, creates a mask to bevel/chamfer and/or round/fillet
|
// passed no children, creates a mask to bevel/chamfer and/or round
|
||||||
// one or both ends of the cylindrical region. Difference the mask
|
// one or both ends of the cylindrical region. Difference the mask
|
||||||
// from the region, making sure the center of the mask object is anchored
|
// from the region, making sure the center of the mask object is
|
||||||
// exactly with the center of the cylindrical region to be chamferred.
|
// anchored exactly with the center of the cylindrical region to
|
||||||
|
// be chamferred.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// l = Length of the cylindrical/conical region.
|
// l = Length of the cylindrical/conical region.
|
||||||
// r = Radius of cylindrical region to chamfer.
|
// r = Radius of cylindrical region to chamfer.
|
||||||
|
@ -105,9 +106,9 @@ module angle_pie_mask(
|
||||||
// chamfang = Angle of chamfers/bevels in degrees from the length axis of the region. (Default: 45)
|
// chamfang = Angle of chamfers/bevels in degrees from the length axis of the region. (Default: 45)
|
||||||
// chamfang1 = Angle of chamfer/bevel of the axis-negative end of the region, in degrees from the length axis.
|
// chamfang1 = Angle of chamfer/bevel of the axis-negative end of the region, in degrees from the length axis.
|
||||||
// chamfang2 = Angle of chamfer/bevel of the axis-positive end of the region, in degrees from the length axis.
|
// chamfang2 = Angle of chamfer/bevel of the axis-positive end of the region, in degrees from the length axis.
|
||||||
// fillet = The radius of the fillets on the ends of the region. Default: none.
|
// rounding = The radius of the rounding on the ends of the region. Default: none.
|
||||||
// fillet1 = The radius of the fillet on the axis-negative end of the region.
|
// rounding1 = The radius of the rounding on the axis-negative end of the region.
|
||||||
// fillet2 = The radius of the fillet on the axis-positive end of the region.
|
// rounding2 = The radius of the rounding on the axis-positive end of the region.
|
||||||
// circum = If true, region will circumscribe the circle of the given radius/diameter.
|
// circum = If true, region will circumscribe the circle of the given radius/diameter.
|
||||||
// from_end = If true, chamfer/bevel size is measured from end of region. If false, chamfer/bevel is measured outset from the radius of the region. (Default: false)
|
// from_end = If true, chamfer/bevel size is measured from end of region. If false, chamfer/bevel is measured outset from the radius of the region. (Default: false)
|
||||||
// overage = The extra thickness of the mask. Default: `10`.
|
// overage = The extra thickness of the mask. Default: `10`.
|
||||||
|
@ -120,7 +121,7 @@ module angle_pie_mask(
|
||||||
// cylinder_mask(l=100, r1=60, r2=30, chamfer=10, from_end=true);
|
// cylinder_mask(l=100, r1=60, r2=30, chamfer=10, from_end=true);
|
||||||
// }
|
// }
|
||||||
// Example:
|
// Example:
|
||||||
// cylinder_mask(l=100, r=50, chamfer1=10, fillet2=10) {
|
// cylinder_mask(l=100, r=50, chamfer1=10, rounding2=10) {
|
||||||
// cube([100,50,100], center=true);
|
// cube([100,50,100], center=true);
|
||||||
// }
|
// }
|
||||||
module cylinder_mask(
|
module cylinder_mask(
|
||||||
|
@ -129,7 +130,7 @@ module cylinder_mask(
|
||||||
d=undef, d1=undef, d2=undef,
|
d=undef, d1=undef, d2=undef,
|
||||||
chamfer=undef, chamfer1=undef, chamfer2=undef,
|
chamfer=undef, chamfer1=undef, chamfer2=undef,
|
||||||
chamfang=undef, chamfang1=undef, chamfang2=undef,
|
chamfang=undef, chamfang1=undef, chamfang2=undef,
|
||||||
fillet=undef, fillet1=undef, fillet2=undef,
|
rounding=undef, rounding1=undef, rounding2=undef,
|
||||||
circum=false, from_end=false,
|
circum=false, from_end=false,
|
||||||
overage=10, ends_only=false,
|
overage=10, ends_only=false,
|
||||||
orient=ORIENT_Z, anchor=CENTER
|
orient=ORIENT_Z, anchor=CENTER
|
||||||
|
@ -143,13 +144,13 @@ module cylinder_mask(
|
||||||
ang2 = first_defined([chamfang2, chamfang, 90-vang]);
|
ang2 = first_defined([chamfang2, chamfang, 90-vang]);
|
||||||
cham1 = first_defined([chamfer1, chamfer, 0]);
|
cham1 = first_defined([chamfer1, chamfer, 0]);
|
||||||
cham2 = first_defined([chamfer2, chamfer, 0]);
|
cham2 = first_defined([chamfer2, chamfer, 0]);
|
||||||
fil1 = first_defined([fillet1, fillet, 0]);
|
fil1 = first_defined([rounding1, rounding, 0]);
|
||||||
fil2 = first_defined([fillet2, fillet, 0]);
|
fil2 = first_defined([rounding2, rounding, 0]);
|
||||||
maxd = max(r1,r2);
|
maxd = max(r1,r2);
|
||||||
if ($children > 0) {
|
if ($children > 0) {
|
||||||
difference() {
|
difference() {
|
||||||
children();
|
children();
|
||||||
cylinder_mask(l=l, r1=sc*r1, r2=sc*r2, chamfer1=cham1, chamfer2=cham2, chamfang1=ang1, chamfang2=ang2, fillet1=fil1, fillet2=fil2, orient=orient, from_end=from_end);
|
cylinder_mask(l=l, r1=sc*r1, r2=sc*r2, chamfer1=cham1, chamfer2=cham2, chamfang1=ang1, chamfang2=ang2, rounding1=fil1, rounding2=fil2, orient=orient, from_end=from_end);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
orient_and_anchor([2*r1, 2*r1, l], orient, anchor, chain=true) {
|
orient_and_anchor([2*r1, 2*r1, l], orient, anchor, chain=true) {
|
||||||
|
@ -166,7 +167,7 @@ module cylinder_mask(
|
||||||
if (fil1>0) down(l/2+overage) cylinder(r=maxd+overage, h=fil1+overage, center=false);
|
if (fil1>0) down(l/2+overage) cylinder(r=maxd+overage, h=fil1+overage, center=false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cyl(r1=sc*r1, r2=sc*r2, l=l, chamfer1=cham1, chamfer2=cham2, chamfang1=ang1, chamfang2=ang2, from_end=from_end, fillet1=fil1, fillet2=fil2);
|
cyl(r1=sc*r1, r2=sc*r2, l=l, chamfer1=cham1, chamfer2=cham2, chamfang1=ang1, chamfang2=ang2, from_end=from_end, rounding1=fil1, rounding2=fil2);
|
||||||
}
|
}
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
|
@ -371,26 +372,26 @@ module chamfer_hole_mask(r=undef, d=undef, chamfer=0.25, ang=45, from_end=false,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Section: Filleting/Rounding
|
// Section: Rounding
|
||||||
|
|
||||||
// Module: fillet_mask()
|
// Module: rounding_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// fillet_mask(l|h, r, [orient], [anchor])
|
// rounding_mask(l|h, r, [orient], [anchor])
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a shape that can be used to fillet a vertical 90 degree edge.
|
// Creates a shape that can be used to round a vertical 90 degree edge.
|
||||||
// Difference it from the object to be filletted. The center of the mask
|
// Difference it from the object to be rounded. The center of the mask
|
||||||
// object should align exactly with the edge to be filletted.
|
// object should align exactly with the edge to be rounded.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// l = Length of mask.
|
// l = Length of mask.
|
||||||
// r = Radius of the fillet.
|
// r = Radius of the rounding.
|
||||||
// orient = Orientation of the mask. Use the `ORIENT_` constants from `constants.h`. Default: vertical.
|
// orient = Orientation of the mask. Use the `ORIENT_` constants from `constants.h`. Default: vertical.
|
||||||
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: centered.
|
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: centered.
|
||||||
// Example:
|
// Example:
|
||||||
// difference() {
|
// difference() {
|
||||||
// cube(size=100, center=false);
|
// cube(size=100, center=false);
|
||||||
// #fillet_mask(l=100, r=25, orient=ORIENT_Z, anchor=UP);
|
// #rounding_mask(l=100, r=25, orient=ORIENT_Z, anchor=UP);
|
||||||
// }
|
// }
|
||||||
module fillet_mask(l=undef, r=1.0, orient=ORIENT_Z, anchor=CENTER, h=undef)
|
module rounding_mask(l=undef, r=1.0, orient=ORIENT_Z, anchor=CENTER, h=undef)
|
||||||
{
|
{
|
||||||
l = first_defined([l, h, 1]);
|
l = first_defined([l, h, 1]);
|
||||||
sides = quantup(segs(r),4);
|
sides = quantup(segs(r),4);
|
||||||
|
@ -406,73 +407,73 @@ module fillet_mask(l=undef, r=1.0, orient=ORIENT_Z, anchor=CENTER, h=undef)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Module: fillet_mask_x()
|
// Module: rounding_mask_x()
|
||||||
// Usage:
|
// Usage:
|
||||||
// fillet_mask_x(l, r, [anchor])
|
// rounding_mask_x(l, r, [anchor])
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a shape that can be used to fillet a 90 degree edge oriented
|
// Creates a shape that can be used to round a 90 degree edge oriented
|
||||||
// along the X axis. Difference it from the object to be filletted.
|
// along the X axis. Difference it from the object to be rounded.
|
||||||
// The center of the mask object should align exactly with the edge to
|
// The center of the mask object should align exactly with the edge to
|
||||||
// be filletted.
|
// be rounded.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// l = Length of mask.
|
// l = Length of mask.
|
||||||
// r = Radius of the fillet.
|
// r = Radius of the rounding.
|
||||||
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: centered.
|
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: centered.
|
||||||
// Example:
|
// Example:
|
||||||
// difference() {
|
// difference() {
|
||||||
// cube(size=100, center=false);
|
// cube(size=100, center=false);
|
||||||
// #fillet_mask_x(l=100, r=25, anchor=RIGHT);
|
// #rounding_mask_x(l=100, r=25, anchor=RIGHT);
|
||||||
// }
|
// }
|
||||||
module fillet_mask_x(l=1.0, r=1.0, anchor=CENTER) fillet_mask(l=l, r=r, orient=ORIENT_X, anchor=anchor) children();
|
module rounding_mask_x(l=1.0, r=1.0, anchor=CENTER) rounding_mask(l=l, r=r, orient=ORIENT_X, anchor=anchor) children();
|
||||||
|
|
||||||
|
|
||||||
// Module: fillet_mask_y()
|
// Module: rounding_mask_y()
|
||||||
// Usage:
|
// Usage:
|
||||||
// fillet_mask_y(l, r, [anchor])
|
// rounding_mask_y(l, r, [anchor])
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a shape that can be used to fillet a 90 degree edge oriented
|
// Creates a shape that can be used to round a 90 degree edge oriented
|
||||||
// along the Y axis. Difference it from the object to be filletted.
|
// along the Y axis. Difference it from the object to be rounded.
|
||||||
// The center of the mask object should align exactly with the edge to
|
// The center of the mask object should align exactly with the edge to
|
||||||
// be filletted.
|
// be rounded.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// l = Length of mask.
|
// l = Length of mask.
|
||||||
// r = Radius of the fillet.
|
// r = Radius of the rounding.
|
||||||
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: centered.
|
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: centered.
|
||||||
// Example:
|
// Example:
|
||||||
// difference() {
|
// difference() {
|
||||||
// cube(size=100, center=false);
|
// cube(size=100, center=false);
|
||||||
// right(100) #fillet_mask_y(l=100, r=25, anchor=BACK);
|
// right(100) #rounding_mask_y(l=100, r=25, anchor=BACK);
|
||||||
// }
|
// }
|
||||||
module fillet_mask_y(l=1.0, r=1.0, anchor=CENTER) fillet_mask(l=l, r=r, orient=ORIENT_Y, anchor=anchor) children();
|
module rounding_mask_y(l=1.0, r=1.0, anchor=CENTER) rounding_mask(l=l, r=r, orient=ORIENT_Y, anchor=anchor) children();
|
||||||
|
|
||||||
|
|
||||||
// Module: fillet_mask_z()
|
// Module: rounding_mask_z()
|
||||||
// Usage:
|
// Usage:
|
||||||
// fillet_mask_z(l, r, [anchor])
|
// rounding_mask_z(l, r, [anchor])
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a shape that can be used to fillet a 90 degree edge oriented
|
// Creates a shape that can be used to round a 90 degree edge oriented
|
||||||
// along the Z axis. Difference it from the object to be filletted.
|
// along the Z axis. Difference it from the object to be rounded.
|
||||||
// The center of the mask object should align exactly with the edge to
|
// The center of the mask object should align exactly with the edge to
|
||||||
// be filletted.
|
// be rounded.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// l = Length of mask.
|
// l = Length of mask.
|
||||||
// r = Radius of the fillet.
|
// r = Radius of the rounding.
|
||||||
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: centered.
|
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: centered.
|
||||||
// Example:
|
// Example:
|
||||||
// difference() {
|
// difference() {
|
||||||
// cube(size=100, center=false);
|
// cube(size=100, center=false);
|
||||||
// #fillet_mask_z(l=100, r=25, anchor=UP);
|
// #rounding_mask_z(l=100, r=25, anchor=UP);
|
||||||
// }
|
// }
|
||||||
module fillet_mask_z(l=1.0, r=1.0, anchor=CENTER) fillet_mask(l=l, r=r, orient=ORIENT_Z, anchor=anchor) children();
|
module rounding_mask_z(l=1.0, r=1.0, anchor=CENTER) rounding_mask(l=l, r=r, orient=ORIENT_Z, anchor=anchor) children();
|
||||||
|
|
||||||
|
|
||||||
// Module: fillet()
|
// Module: rounding()
|
||||||
// Usage:
|
// Usage:
|
||||||
// fillet(fillet, size, [edges]) ...
|
// rounding(r, size, [edges]) ...
|
||||||
// Description:
|
// Description:
|
||||||
// Fillets the edges of a cuboid region containing the given children.
|
// Rounds the edges of a cuboid region containing the given children.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// fillet = Radius of the fillet. (Default: 1)
|
// r = Radius of the rounding. (Default: 1)
|
||||||
// size = The size of the rectangular cuboid we want to chamfer.
|
// size = The size of the rectangular cuboid we want to chamfer.
|
||||||
// edges = Which edges do we want to chamfer. Recommend to use EDGE constants from constants.scad.
|
// edges = Which edges do we want to chamfer. Recommend to use EDGE constants from constants.scad.
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -484,45 +485,45 @@ module fillet_mask_z(l=1.0, r=1.0, anchor=CENTER) fillet_mask(l=l, r=r, orient=O
|
||||||
// [X+Y+, X-Y+, X-Y-, X+Y-]
|
// [X+Y+, X-Y+, X-Y-, X+Y-]
|
||||||
// ]
|
// ]
|
||||||
// Example(FR):
|
// Example(FR):
|
||||||
// fillet(fillet=10, size=[50,100,150], $fn=24) {
|
// rounding(r=10, size=[50,100,150], $fn=24) {
|
||||||
// cube(size=[50,100,150], center=true);
|
// cube(size=[50,100,150], center=true);
|
||||||
// }
|
// }
|
||||||
// Example(FR,FlatSpin):
|
// Example(FR,FlatSpin):
|
||||||
// fillet(fillet=10, size=[50,50,75], edges=EDGES_TOP - EDGE_TOP_LF + EDGE_FR_RT, $fn=24) {
|
// rounding(r=10, size=[50,50,75], edges=EDGES_TOP - EDGE_TOP_LF + EDGE_FR_RT, $fn=24) {
|
||||||
// cube(size=[50,50,75], center=true);
|
// cube(size=[50,50,75], center=true);
|
||||||
// }
|
// }
|
||||||
module fillet(fillet=1, size=[1,1,1], edges=EDGES_ALL)
|
module rounding(r=1, size=[1,1,1], edges=EDGES_ALL)
|
||||||
{
|
{
|
||||||
difference() {
|
difference() {
|
||||||
children();
|
children();
|
||||||
difference() {
|
difference() {
|
||||||
cube(size, center=true);
|
cube(size, center=true);
|
||||||
cuboid(size+[1,1,1]*0.01, fillet=fillet, edges=edges, trimcorners=true);
|
cuboid(size+[1,1,1]*0.01, rounding=r, edges=edges, trimcorners=true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Module: fillet_angled_edge_mask()
|
// Module: rounding_angled_edge_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// fillet_angled_edge_mask(h, r, [ang], [orient], [anchor]);
|
// rounding_angled_edge_mask(h, r, [ang], [orient], [anchor]);
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a vertical mask that can be used to fillet the edge where two
|
// Creates a vertical mask that can be used to round the edge where two
|
||||||
// face meet, at any arbitrary angle. Difference it from the object to
|
// face meet, at any arbitrary angle. Difference it from the object to
|
||||||
// be filletted. The center of the mask should align exactly with the
|
// be rounded. The center of the mask should align exactly with the
|
||||||
// edge to be filletted.
|
// edge to be rounded.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// h = height of vertical mask.
|
// h = height of vertical mask.
|
||||||
// r = radius of the fillet.
|
// r = radius of the rounding.
|
||||||
// ang = angle that the planes meet at.
|
// ang = angle that the planes meet at.
|
||||||
// orient = Orientation of the mask. Use the `ORIENT_` constants from `constants.h`. Default: `ORIENT_Z`.
|
// orient = Orientation of the mask. Use the `ORIENT_` constants from `constants.h`. Default: `ORIENT_Z`.
|
||||||
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: `CENTER`.
|
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: `CENTER`.
|
||||||
// Example:
|
// Example:
|
||||||
// difference() {
|
// difference() {
|
||||||
// angle_pie_mask(ang=70, h=50, d=100);
|
// angle_pie_mask(ang=70, h=50, d=100);
|
||||||
// #fillet_angled_edge_mask(h=51, r=20.0, ang=70, $fn=32);
|
// #rounding_angled_edge_mask(h=51, r=20.0, ang=70, $fn=32);
|
||||||
// }
|
// }
|
||||||
module fillet_angled_edge_mask(h=1.0, r=1.0, ang=90, orient=ORIENT_Z, anchor=CENTER)
|
module rounding_angled_edge_mask(h=1.0, r=1.0, ang=90, orient=ORIENT_Z, anchor=CENTER)
|
||||||
{
|
{
|
||||||
sweep = 180-ang;
|
sweep = 180-ang;
|
||||||
n = ceil(segs(r)*sweep/360);
|
n = ceil(segs(r)*sweep/360);
|
||||||
|
@ -545,16 +546,16 @@ module fillet_angled_edge_mask(h=1.0, r=1.0, ang=90, orient=ORIENT_Z, anchor=CEN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Module: fillet_angled_corner_mask()
|
// Module: rounding_angled_corner_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// fillet_angled_corner_mask(fillet, ang, [orient], [anchor]);
|
// rounding_angled_corner_mask(r, ang, [orient], [anchor]);
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a shape that can be used to fillet the corner of an angle.
|
// Creates a shape that can be used to round the corner of an angle.
|
||||||
// Difference it from the object to be filletted. The center of the mask
|
// Difference it from the object to be rounded. The center of the mask
|
||||||
// object should align exactly with the point of the corner to be filletted.
|
// object should align exactly with the point of the corner to be rounded.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// fillet = radius of the fillet.
|
// r = Radius of the rounding.
|
||||||
// ang = angle between planes that you need to fillet the corner of.
|
// ang = Angle between planes that you need to round the corner of.
|
||||||
// orient = Orientation of the mask. Use the `ORIENT_` constants from `constants.h`. Default: `ORIENT_Z`.
|
// orient = Orientation of the mask. Use the `ORIENT_` constants from `constants.h`. Default: `ORIENT_Z`.
|
||||||
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: `CENTER`.
|
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: `CENTER`.
|
||||||
// Example:
|
// Example:
|
||||||
|
@ -562,26 +563,26 @@ module fillet_angled_edge_mask(h=1.0, r=1.0, ang=90, orient=ORIENT_Z, anchor=CEN
|
||||||
// difference() {
|
// difference() {
|
||||||
// angle_pie_mask(ang=ang, h=50, r=200);
|
// angle_pie_mask(ang=ang, h=50, r=200);
|
||||||
// up(50/2) {
|
// up(50/2) {
|
||||||
// #fillet_angled_corner_mask(fillet=20, ang=ang);
|
// #rounding_angled_corner_mask(r=20, ang=ang);
|
||||||
// zrot_copies([0, ang]) right(200/2) fillet_mask_x(l=200, r=20);
|
// zrot_copies([0, ang]) right(200/2) rounding_mask_x(l=200, r=20);
|
||||||
// }
|
// }
|
||||||
// fillet_angled_edge_mask(h=51, r=20, ang=ang);
|
// rounding_angled_edge_mask(h=51, r=20, ang=ang);
|
||||||
// }
|
// }
|
||||||
module fillet_angled_corner_mask(fillet=1.0, ang=90, orient=ORIENT_Z, anchor=CENTER)
|
module rounding_angled_corner_mask(r=1.0, ang=90, orient=ORIENT_Z, anchor=CENTER)
|
||||||
{
|
{
|
||||||
dx = fillet / tan(ang/2);
|
dx = r / tan(ang/2);
|
||||||
dx2 = dx / cos(ang/2) + 1;
|
dx2 = dx / cos(ang/2) + 1;
|
||||||
fn = quantup(segs(fillet), 4);
|
fn = quantup(segs(r), 4);
|
||||||
orient_and_anchor([2*dx2, 2*dx2, fillet*2], orient, anchor, chain=true) {
|
orient_and_anchor([2*dx2, 2*dx2, r*2], orient, anchor, chain=true) {
|
||||||
difference() {
|
difference() {
|
||||||
down(fillet) cylinder(r=dx2, h=fillet+1, center=false);
|
down(r) cylinder(r=dx2, h=r+1, center=false);
|
||||||
yflip_copy() {
|
yflip_copy() {
|
||||||
translate([dx, fillet, -fillet]) {
|
translate([dx, r, -r]) {
|
||||||
hull() {
|
hull() {
|
||||||
sphere(r=fillet, $fn=fn);
|
sphere(r=r, $fn=fn);
|
||||||
down(fillet*3) sphere(r=fillet, $fn=fn);
|
down(r*3) sphere(r=r, $fn=fn);
|
||||||
zrot_copies([0,ang]) {
|
zrot_copies([0,ang]) {
|
||||||
right(fillet*3) sphere(r=fillet, $fn=fn);
|
right(r*3) sphere(r=r, $fn=fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,27 +593,27 @@ module fillet_angled_corner_mask(fillet=1.0, ang=90, orient=ORIENT_Z, anchor=CEN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Module: fillet_corner_mask()
|
// Module: rounding_corner_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// fillet_corner_mask(r, [anchor]);
|
// rounding_corner_mask(r, [anchor]);
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a shape that you can use to round 90 degree corners on a fillet.
|
// Creates a shape that you can use to round 90 degree corners.
|
||||||
// Difference it from the object to be filletted. The center of the mask
|
// Difference it from the object to be rounded. The center of the mask
|
||||||
// object should align exactly with the corner to be filletted.
|
// object should align exactly with the corner to be rounded.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// r = radius of corner fillet.
|
// r = Radius of corner rounding.
|
||||||
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: `CENTER`.
|
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: `CENTER`.
|
||||||
// Example:
|
// Example:
|
||||||
// fillet_corner_mask(r=20.0);
|
// rounding_corner_mask(r=20.0);
|
||||||
// Example:
|
// Example:
|
||||||
// difference() {
|
// difference() {
|
||||||
// cube(size=[30, 50, 80], center=true);
|
// cube(size=[30, 50, 80], center=true);
|
||||||
// translate([0, 25, 40]) fillet_mask_x(l=31, r=15);
|
// translate([0, 25, 40]) rounding_mask_x(l=31, r=15);
|
||||||
// translate([15, 0, 40]) fillet_mask_y(l=51, r=15);
|
// translate([15, 0, 40]) rounding_mask_y(l=51, r=15);
|
||||||
// translate([15, 25, 0]) fillet_mask_z(l=81, r=15);
|
// translate([15, 25, 0]) rounding_mask_z(l=81, r=15);
|
||||||
// translate([15, 25, 40]) #fillet_corner_mask(r=15);
|
// translate([15, 25, 40]) #rounding_corner_mask(r=15);
|
||||||
// }
|
// }
|
||||||
module fillet_corner_mask(r=1.0, anchor=CENTER)
|
module rounding_corner_mask(r=1.0, anchor=CENTER)
|
||||||
{
|
{
|
||||||
orient_and_anchor([2*r, 2*r, 2*r], ORIENT_Z, anchor, chain=true) {
|
orient_and_anchor([2*r, 2*r, 2*r], ORIENT_Z, anchor, chain=true) {
|
||||||
difference() {
|
difference() {
|
||||||
|
@ -626,46 +627,46 @@ module fillet_corner_mask(r=1.0, anchor=CENTER)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Module: fillet_cylinder_mask()
|
// Module: rounding_cylinder_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// fillet_cylinder_mask(r, fillet);
|
// rounding_cylinder_mask(r, rounding);
|
||||||
// Description:
|
// Description:
|
||||||
// Create a mask that can be used to round the end of a cylinder.
|
// Create a mask that can be used to round the end of a cylinder.
|
||||||
// Difference it from the cylinder to be filletted. The center of the
|
// Difference it from the cylinder to be rounded. The center of the
|
||||||
// mask object should align exactly with the center of the end of the
|
// mask object should align exactly with the center of the end of the
|
||||||
// cylinder to be filletted.
|
// cylinder to be rounded.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// r = radius of cylinder to fillet. (Default: 1.0)
|
// r = Radius of cylinder. (Default: 1.0)
|
||||||
// fillet = radius of the edge filleting. (Default: 0.25)
|
// rounding = Radius of the edge rounding. (Default: 0.25)
|
||||||
// Example:
|
// Example:
|
||||||
// difference() {
|
// difference() {
|
||||||
// cylinder(r=50, h=50, center=false);
|
// cylinder(r=50, h=50, center=false);
|
||||||
// up(50) #fillet_cylinder_mask(r=50, fillet=10);
|
// up(50) #rounding_cylinder_mask(r=50, rounding=10);
|
||||||
// }
|
// }
|
||||||
// Example:
|
// Example:
|
||||||
// difference() {
|
// difference() {
|
||||||
// cylinder(r=50, h=100, center=false);
|
// cylinder(r=50, h=100, center=false);
|
||||||
// up(75) fillet_cylinder_mask(r=50, fillet=10);
|
// up(75) rounding_cylinder_mask(r=50, rounding=10);
|
||||||
// }
|
// }
|
||||||
module fillet_cylinder_mask(r=1.0, fillet=0.25)
|
module rounding_cylinder_mask(r=1.0, rounding=0.25)
|
||||||
{
|
{
|
||||||
cylinder_mask(l=fillet*3, r=r, fillet2=fillet, overage=fillet, ends_only=true, anchor=DOWN) children();
|
cylinder_mask(l=rounding*3, r=r, rounding2=rounding, overage=rounding, ends_only=true, anchor=DOWN) children();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Module: fillet_hole_mask()
|
// Module: rounding_hole_mask()
|
||||||
// Usage:
|
// Usage:
|
||||||
// fillet_hole_mask(r|d, fillet);
|
// rounding_hole_mask(r|d, rounding);
|
||||||
// Description:
|
// Description:
|
||||||
// Create a mask that can be used to round the edge of a circular hole.
|
// Create a mask that can be used to round the edge of a circular hole.
|
||||||
// Difference it from the hole to be filletted. The center of the
|
// Difference it from the hole to be rounded. The center of the
|
||||||
// mask object should align exactly with the center of the end of the
|
// mask object should align exactly with the center of the end of the
|
||||||
// hole to be filletted.
|
// hole to be rounded.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// r = Radius of hole to fillet.
|
// r = Radius of hole.
|
||||||
// d = Diameter of hole to fillet.
|
// d = Diameter of hole to rounding.
|
||||||
// fillet = Radius of the filleting. (Default: 0.25)
|
// rounding = Radius of the rounding. (Default: 0.25)
|
||||||
// overage = The extra thickness of the mask. Default: `0.1`.
|
// overage = The extra thickness of the mask. Default: `0.1`.
|
||||||
// orient = Orientation of the mask. Use the `ORIENT_` constants from `constants.h`. Default: `ORIENT_Z`.
|
// orient = Orientation of the mask. Use the `ORIENT_` constants from `constants.h`. Default: `ORIENT_Z`.
|
||||||
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: `CENTER`.
|
// anchor = Alignment of the mask. Use the constants from `constants.h`. Default: `CENTER`.
|
||||||
|
@ -673,18 +674,18 @@ module fillet_cylinder_mask(r=1.0, fillet=0.25)
|
||||||
// difference() {
|
// difference() {
|
||||||
// cube([150,150,100], center=true);
|
// cube([150,150,100], center=true);
|
||||||
// cylinder(r=50, h=100.1, center=true);
|
// cylinder(r=50, h=100.1, center=true);
|
||||||
// up(50) #fillet_hole_mask(r=50, fillet=10);
|
// up(50) #rounding_hole_mask(r=50, rounding=10);
|
||||||
// }
|
// }
|
||||||
// Example:
|
// Example:
|
||||||
// fillet_hole_mask(r=40, fillet=20, $fa=2, $fs=2);
|
// rounding_hole_mask(r=40, rounding=20, $fa=2, $fs=2);
|
||||||
module fillet_hole_mask(r=undef, d=undef, fillet=0.25, overage=0.1, orient=ORIENT_Z, anchor=CENTER)
|
module rounding_hole_mask(r=undef, d=undef, rounding=0.25, overage=0.1, orient=ORIENT_Z, anchor=CENTER)
|
||||||
{
|
{
|
||||||
r = get_radius(r=r, d=d, dflt=1);
|
r = get_radius(r=r, d=d, dflt=1);
|
||||||
orient_and_anchor([2*(r+fillet), 2*(r+fillet), fillet*2], orient, anchor, chain=true) {
|
orient_and_anchor([2*(r+rounding), 2*(r+rounding), rounding*2], orient, anchor, chain=true) {
|
||||||
rotate_extrude(convexity=4) {
|
rotate_extrude(convexity=4) {
|
||||||
difference() {
|
difference() {
|
||||||
right(r-overage) fwd(fillet) square(fillet+overage, center=false);
|
right(r-overage) fwd(rounding) square(rounding+overage, center=false);
|
||||||
right(r+fillet) fwd(fillet) circle(r=fillet);
|
right(r+rounding) fwd(rounding) circle(r=rounding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
children();
|
children();
|
||||||
|
|
|
@ -576,7 +576,7 @@ module metric_bolt(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (headtype == "pan") {
|
} else if (headtype == "pan") {
|
||||||
cyl(l=H*0.75, d=D, fillet2=H*0.75/2, anchor=DOWN);
|
cyl(l=H*0.75, d=D, rounding2=H*0.75/2, anchor=DOWN);
|
||||||
} else if (headtype == "round") {
|
} else if (headtype == "round") {
|
||||||
top_half(D) zscale(H*0.75/D*2) sphere(d=D);
|
top_half(D) zscale(H*0.75/D*2) sphere(d=D);
|
||||||
} else if (headtype == "button") {
|
} else if (headtype == "button") {
|
||||||
|
|
110
shapes.scad
110
shapes.scad
|
@ -43,14 +43,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// Module: cuboid()
|
// Module: cuboid()
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
// Creates a cube or cuboid object, with optional chamfering or filleting/rounding.
|
// Creates a cube or cuboid object, with optional chamfering or rounding.
|
||||||
//
|
//
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// size = The size of the cube.
|
// size = The size of the cube.
|
||||||
// chamfer = Size of chamfer, inset from sides. Default: No chamferring.
|
// chamfer = Size of chamfer, inset from sides. Default: No chamferring.
|
||||||
// fillet = Radius of fillet for edge rounding. Default: No filleting.
|
// rounding = Radius of the edge rounding. Default: No rounding.
|
||||||
// edges = Edges to chamfer/fillet. Use `EDGE` constants from constants.scad. Default: `EDGES_ALL`
|
// edges = Edges to chamfer/rounding. Use `EDGE` constants from constants.scad. Default: `EDGES_ALL`
|
||||||
// trimcorners = If true, rounds or chamfers corners where three chamferred/filleted edges meet. Default: `true`
|
// trimcorners = If true, rounds or chamfers corners where three chamferred/rounded edges meet. Default: `true`
|
||||||
// p1 = Align the cuboid's corner at `p1`, if given. Forces `anchor=ALLNEG`.
|
// p1 = Align the cuboid's corner at `p1`, if given. Forces `anchor=ALLNEG`.
|
||||||
// p2 = If given with `p1`, defines the cornerpoints of the cuboid.
|
// p2 = If given with `p1`, defines the cornerpoints of the cuboid.
|
||||||
// anchor = The side of the part to anchor to. Use constants from `constants.scad`. Default: `CENTER`
|
// anchor = The side of the part to anchor to. Use constants from `constants.scad`. Default: `CENTER`
|
||||||
|
@ -69,20 +69,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// Example: Rectangular cube with chamferred edges, without trimmed corners.
|
// Example: Rectangular cube with chamferred edges, without trimmed corners.
|
||||||
// cuboid([30,40,50], chamfer=5, trimcorners=false);
|
// cuboid([30,40,50], chamfer=5, trimcorners=false);
|
||||||
// Example: Rectangular cube with rounded edges and corners.
|
// Example: Rectangular cube with rounded edges and corners.
|
||||||
// cuboid([30,40,50], fillet=10);
|
// cuboid([30,40,50], rounding=10);
|
||||||
// Example: Rectangular cube with rounded edges, without trimmed corners.
|
// Example: Rectangular cube with rounded edges, without trimmed corners.
|
||||||
// cuboid([30,40,50], fillet=10, trimcorners=false);
|
// cuboid([30,40,50], rounding=10, trimcorners=false);
|
||||||
// Example: Rectangular cube with only some edges chamferred.
|
// Example: Rectangular cube with only some edges chamferred.
|
||||||
// cuboid([30,40,50], chamfer=5, edges=EDGE_TOP_FR+EDGE_TOP_RT+EDGE_FR_RT, $fn=24);
|
// cuboid([30,40,50], chamfer=5, edges=EDGE_TOP_FR+EDGE_TOP_RT+EDGE_FR_RT, $fn=24);
|
||||||
// Example: Rectangular cube with only some edges rounded.
|
// Example: Rectangular cube with only some edges rounded.
|
||||||
// cuboid([30,40,50], fillet=5, edges=EDGE_TOP_FR+EDGE_TOP_RT+EDGE_FR_RT, $fn=24);
|
// cuboid([30,40,50], rounding=5, edges=EDGE_TOP_FR+EDGE_TOP_RT+EDGE_FR_RT, $fn=24);
|
||||||
// Example: Standard Connectors
|
// Example: Standard Connectors
|
||||||
// cuboid(40, chamfer=5) show_anchors();
|
// cuboid(40, chamfer=5) show_anchors();
|
||||||
module cuboid(
|
module cuboid(
|
||||||
size=[1,1,1],
|
size=[1,1,1],
|
||||||
p1=undef, p2=undef,
|
p1=undef, p2=undef,
|
||||||
chamfer=undef,
|
chamfer=undef,
|
||||||
fillet=undef,
|
rounding=undef,
|
||||||
edges=EDGES_ALL,
|
edges=EDGES_ALL,
|
||||||
trimcorners=true,
|
trimcorners=true,
|
||||||
anchor=CENTER,
|
anchor=CENTER,
|
||||||
|
@ -92,16 +92,16 @@ module cuboid(
|
||||||
if (!is_undef(p1)) {
|
if (!is_undef(p1)) {
|
||||||
if (!is_undef(p2)) {
|
if (!is_undef(p2)) {
|
||||||
translate(pointlist_bounds([p1,p2])[0]) {
|
translate(pointlist_bounds([p1,p2])[0]) {
|
||||||
cuboid(size=vabs(p2-p1), chamfer=chamfer, fillet=fillet, edges=edges, trimcorners=trimcorners, anchor=ALLNEG) children();
|
cuboid(size=vabs(p2-p1), chamfer=chamfer, rounding=rounding, edges=edges, trimcorners=trimcorners, anchor=ALLNEG) children();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
translate(p1) {
|
translate(p1) {
|
||||||
cuboid(size=size, chamfer=chamfer, fillet=fillet, edges=edges, trimcorners=trimcorners, anchor=ALLNEG) children();
|
cuboid(size=size, chamfer=chamfer, rounding=rounding, edges=edges, trimcorners=trimcorners, anchor=ALLNEG) children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (chamfer != undef) assert(chamfer <= min(size)/2, "chamfer must be smaller than half the cube width, length, or height.");
|
if (chamfer != undef) assert(chamfer <= min(size)/2, "chamfer must be smaller than half the cube width, length, or height.");
|
||||||
if (fillet != undef) assert(fillet <= min(size)/2, "fillet must be smaller than half the cube width, length, or height.");
|
if (rounding != undef) assert(rounding <= min(size)/2, "rounding radius must be smaller than half the cube width, length, or height.");
|
||||||
majrots = [[0,90,0], [90,0,0], [0,0,0]];
|
majrots = [[0,90,0], [90,0,0], [0,0,0]];
|
||||||
orient_and_anchor(size, ORIENT_Z, anchor, center=center, noncentered=ALLPOS, chain=true) {
|
orient_and_anchor(size, ORIENT_Z, anchor, center=center, noncentered=ALLPOS, chain=true) {
|
||||||
if (chamfer != undef) {
|
if (chamfer != undef) {
|
||||||
|
@ -141,20 +141,20 @@ module cuboid(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fillet != undef) {
|
} else if (rounding != undef) {
|
||||||
sides = quantup(segs(fillet),4);
|
sides = quantup(segs(rounding),4);
|
||||||
sc = 1/cos(180/sides);
|
sc = 1/cos(180/sides);
|
||||||
isize = [for (v = size) max(0.001, v-2*fillet)];
|
isize = [for (v = size) max(0.001, v-2*rounding)];
|
||||||
if (edges == EDGES_ALL) {
|
if (edges == EDGES_ALL) {
|
||||||
minkowski() {
|
minkowski() {
|
||||||
cube(isize, center=true);
|
cube(isize, center=true);
|
||||||
if (trimcorners) {
|
if (trimcorners) {
|
||||||
sphere(r=fillet*sc, $fn=sides);
|
sphere(r=rounding*sc, $fn=sides);
|
||||||
} else {
|
} else {
|
||||||
intersection() {
|
intersection() {
|
||||||
zrot(180/sides) cylinder(r=fillet*sc, h=fillet*2, center=true, $fn=sides);
|
zrot(180/sides) cylinder(r=rounding*sc, h=rounding*2, center=true, $fn=sides);
|
||||||
rotate([90,0,0]) zrot(180/sides) cylinder(r=fillet*sc, h=fillet*2, center=true, $fn=sides);
|
rotate([90,0,0]) zrot(180/sides) cylinder(r=rounding*sc, h=rounding*2, center=true, $fn=sides);
|
||||||
rotate([0,90,0]) zrot(180/sides) cylinder(r=fillet*sc, h=fillet*2, center=true, $fn=sides);
|
rotate([0,90,0]) zrot(180/sides) cylinder(r=rounding*sc, h=rounding*2, center=true, $fn=sides);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,10 +167,10 @@ module cuboid(
|
||||||
if (edges[axis][i]>0) {
|
if (edges[axis][i]>0) {
|
||||||
difference() {
|
difference() {
|
||||||
translate(vmul(EDGE_OFFSETS[axis][i], size/2)) {
|
translate(vmul(EDGE_OFFSETS[axis][i], size/2)) {
|
||||||
rotate(majrots[axis]) cube([fillet*2, fillet*2, size[axis]+0.1], center=true);
|
rotate(majrots[axis]) cube([rounding*2, rounding*2, size[axis]+0.1], center=true);
|
||||||
}
|
}
|
||||||
translate(vmul(EDGE_OFFSETS[axis][i], size/2 - [1,1,1]*fillet)) {
|
translate(vmul(EDGE_OFFSETS[axis][i], size/2 - [1,1,1]*rounding)) {
|
||||||
rotate(majrots[axis]) zrot(180/sides) cylinder(h=size[axis]+0.2, r=fillet*sc, center=true, $fn=sides);
|
rotate(majrots[axis]) zrot(180/sides) cylinder(h=size[axis]+0.2, r=rounding*sc, center=true, $fn=sides);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,10 +182,10 @@ module cuboid(
|
||||||
if (corner_edge_count(edges, [xa,ya,za]) > 2) {
|
if (corner_edge_count(edges, [xa,ya,za]) > 2) {
|
||||||
difference() {
|
difference() {
|
||||||
translate(vmul([xa,ya,za], size/2)) {
|
translate(vmul([xa,ya,za], size/2)) {
|
||||||
cube(fillet*2, center=true);
|
cube(rounding*2, center=true);
|
||||||
}
|
}
|
||||||
translate(vmul([xa,ya,za], size/2-[1,1,1]*fillet)) {
|
translate(vmul([xa,ya,za], size/2-[1,1,1]*rounding)) {
|
||||||
zrot(180/sides) sphere(r=fillet*sc*sc, $fn=sides);
|
zrot(180/sides) sphere(r=rounding*sc*sc, $fn=sides);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,9 +291,9 @@ module prismoid(
|
||||||
// size1 = [width, length] of the bottom of the prism.
|
// size1 = [width, length] of the bottom of the prism.
|
||||||
// size2 = [width, length] of the top of the prism.
|
// size2 = [width, length] of the top of the prism.
|
||||||
// h = Height of the prism.
|
// h = Height of the prism.
|
||||||
// r = radius of vertical edge fillets.
|
// r = radius of vertical edge rounding.
|
||||||
// r1 = radius of vertical edge fillets at bottom.
|
// r1 = radius of vertical edge rounding at bottom.
|
||||||
// r2 = radius of vertical edge fillets at top.
|
// r2 = radius of vertical edge rounding at top.
|
||||||
// shift = [x, y] amount to shift the center of the top with respect to the center of the bottom.
|
// shift = [x, y] amount to shift the center of the top with respect to the center of the bottom.
|
||||||
// orient = Orientation of the prismoid. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
|
// orient = Orientation of the prismoid. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
|
||||||
// anchor = Alignment of the prismoid by the axis-negative (`size1`) end. Use the constants from `constants.scad`. Default: `BOTTOM`.
|
// anchor = Alignment of the prismoid by the axis-negative (`size1`) end. Use the constants from `constants.scad`. Default: `BOTTOM`.
|
||||||
|
@ -410,10 +410,10 @@ module right_triangle(size=[1, 1, 1], orient=ORIENT_Y, anchor=ALLNEG, center=und
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
// Creates cylinders in various anchors and orientations,
|
// Creates cylinders in various anchors and orientations,
|
||||||
// with optional fillets and chamfers. You can use `r` and `l`
|
// with optional rounding and chamfers. You can use `r` and `l`
|
||||||
// interchangably, and all variants allow specifying size
|
// interchangably, and all variants allow specifying size
|
||||||
// by either `r`|`d`, or `r1`|`d1` and `r2`|`d2`.
|
// by either `r`|`d`, or `r1`|`d1` and `r2`|`d2`.
|
||||||
// Note that that chamfers and fillets cannot cross the
|
// Note that that chamfers and rounding cannot cross the
|
||||||
// midpoint of the cylinder's length.
|
// midpoint of the cylinder's length.
|
||||||
//
|
//
|
||||||
// Usage: Normal Cylinders
|
// Usage: Normal Cylinders
|
||||||
|
@ -426,11 +426,11 @@ module right_triangle(size=[1, 1, 1], orient=ORIENT_Y, anchor=ALLNEG, center=und
|
||||||
// cyl(l|h, r|d, chamfer2, [chamfang2], [from_end], [circum], [realign], [orient], [anchor], [center]);
|
// cyl(l|h, r|d, chamfer2, [chamfang2], [from_end], [circum], [realign], [orient], [anchor], [center]);
|
||||||
// cyl(l|h, r|d, chamfer1, chamfer2, [chamfang1], [chamfang2], [from_end], [circum], [realign], [orient], [anchor], [center]);
|
// cyl(l|h, r|d, chamfer1, chamfer2, [chamfang1], [chamfang2], [from_end], [circum], [realign], [orient], [anchor], [center]);
|
||||||
//
|
//
|
||||||
// Usage: Rounded/Filleted Cylinders
|
// Usage: Rounded End Cylinders
|
||||||
// cyl(l|h, r|d, fillet, [circum], [realign], [orient], [anchor], [center]);
|
// cyl(l|h, r|d, rounding, [circum], [realign], [orient], [anchor], [center]);
|
||||||
// cyl(l|h, r|d, fillet1, [circum], [realign], [orient], [anchor], [center]);
|
// cyl(l|h, r|d, rounding1, [circum], [realign], [orient], [anchor], [center]);
|
||||||
// cyl(l|h, r|d, fillet2, [circum], [realign], [orient], [anchor], [center]);
|
// cyl(l|h, r|d, rounding2, [circum], [realign], [orient], [anchor], [center]);
|
||||||
// cyl(l|h, r|d, fillet1, fillet2, [circum], [realign], [orient], [anchor], [center]);
|
// cyl(l|h, r|d, rounding1, rounding2, [circum], [realign], [orient], [anchor], [center]);
|
||||||
//
|
//
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// l / h = Length of cylinder along oriented axis. (Default: 1.0)
|
// l / h = Length of cylinder along oriented axis. (Default: 1.0)
|
||||||
|
@ -448,9 +448,9 @@ module right_triangle(size=[1, 1, 1], orient=ORIENT_Y, anchor=ALLNEG, center=und
|
||||||
// chamfang1 = The angle in degrees of the chamfer on the axis-negative end of the cylinder.
|
// chamfang1 = The angle in degrees of the chamfer on the axis-negative end of the cylinder.
|
||||||
// chamfang2 = The angle in degrees of the chamfer on the axis-positive end of the cylinder.
|
// chamfang2 = The angle in degrees of the chamfer on the axis-positive end of the cylinder.
|
||||||
// from_end = If true, chamfer is measured from the end of the cylinder, instead of inset from the edge. Default: `false`.
|
// from_end = If true, chamfer is measured from the end of the cylinder, instead of inset from the edge. Default: `false`.
|
||||||
// fillet = The radius of the fillets on the ends of the cylinder. Default: none.
|
// rounding = The radius of the rounding on the ends of the cylinder. Default: none.
|
||||||
// fillet1 = The radius of the fillet on the axis-negative end of the cylinder.
|
// rounding1 = The radius of the rounding on the axis-negative end of the cylinder.
|
||||||
// fillet2 = The radius of the fillet on the axis-positive end of the cylinder.
|
// rounding2 = The radius of the rounding on the axis-positive end of the cylinder.
|
||||||
// realign = If true, rotate the cylinder by half the angle of one face.
|
// realign = If true, rotate the cylinder by half the angle of one face.
|
||||||
// orient = Orientation of the cylinder. Use the `ORIENT_` constants from `constants.scad`. Default: vertical.
|
// orient = Orientation of the cylinder. Use the `ORIENT_` constants from `constants.scad`. Default: vertical.
|
||||||
// anchor = Alignment of the cylinder. Use the constants from `constants.scad`. Default: centered.
|
// anchor = Alignment of the cylinder. Use the constants from `constants.scad`. Default: centered.
|
||||||
|
@ -476,19 +476,19 @@ module right_triangle(size=[1, 1, 1], orient=ORIENT_Y, anchor=ALLNEG, center=und
|
||||||
// cyl(l=40, d=40, chamfer=7, chamfang=30, from_end=true);
|
// cyl(l=40, d=40, chamfer=7, chamfang=30, from_end=true);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Example: Rounding/Filleting
|
// Example: Rounding
|
||||||
// cyl(l=40, d=40, fillet=10);
|
// cyl(l=40, d=40, rounding=10);
|
||||||
//
|
//
|
||||||
// Example: Heterogenous Chamfers and Fillets
|
// Example: Heterogenous Chamfers and Rounding
|
||||||
// ydistribute(80) {
|
// ydistribute(80) {
|
||||||
// // Shown Front to Back.
|
// // Shown Front to Back.
|
||||||
// cyl(l=40, d=40, fillet1=15, orient=ORIENT_X);
|
// cyl(l=40, d=40, rounding1=15, orient=ORIENT_X);
|
||||||
// cyl(l=40, d=40, chamfer2=5, orient=ORIENT_X);
|
// cyl(l=40, d=40, chamfer2=5, orient=ORIENT_X);
|
||||||
// cyl(l=40, d=40, chamfer1=12, fillet2=10, orient=ORIENT_X);
|
// cyl(l=40, d=40, chamfer1=12, rounding2=10, orient=ORIENT_X);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Example: Putting it all together
|
// Example: Putting it all together
|
||||||
// cyl(l=40, d1=25, d2=15, chamfer1=10, chamfang1=30, from_end=true, fillet2=5);
|
// cyl(l=40, d1=25, d2=15, chamfer1=10, chamfang1=30, from_end=true, rounding2=5);
|
||||||
//
|
//
|
||||||
// Example: Standard Connectors
|
// Example: Standard Connectors
|
||||||
// xdistribute(40) {
|
// xdistribute(40) {
|
||||||
|
@ -502,7 +502,7 @@ module cyl(
|
||||||
d=undef, d1=undef, d2=undef,
|
d=undef, d1=undef, d2=undef,
|
||||||
chamfer=undef, chamfer1=undef, chamfer2=undef,
|
chamfer=undef, chamfer1=undef, chamfer2=undef,
|
||||||
chamfang=undef, chamfang1=undef, chamfang2=undef,
|
chamfang=undef, chamfang1=undef, chamfang2=undef,
|
||||||
fillet=undef, fillet1=undef, fillet2=undef,
|
rounding=undef, rounding1=undef, rounding2=undef,
|
||||||
circum=false, realign=false, from_end=false,
|
circum=false, realign=false, from_end=false,
|
||||||
orient=ORIENT_Z, anchor=CENTER, center=undef
|
orient=ORIENT_Z, anchor=CENTER, center=undef
|
||||||
) {
|
) {
|
||||||
|
@ -516,7 +516,7 @@ module cyl(
|
||||||
phi = atan2(l, r1-r2);
|
phi = atan2(l, r1-r2);
|
||||||
orient_and_anchor(size1, orient, anchor, center=center, size2=size2, geometry="cylinder", chain=true) {
|
orient_and_anchor(size1, orient, anchor, center=center, size2=size2, geometry="cylinder", chain=true) {
|
||||||
zrot(realign? 180/sides : 0) {
|
zrot(realign? 180/sides : 0) {
|
||||||
if (!any_defined([chamfer, chamfer1, chamfer2, fillet, fillet1, fillet2])) {
|
if (!any_defined([chamfer, chamfer1, chamfer2, rounding, rounding1, rounding2])) {
|
||||||
cylinder(h=l, r1=r1*sc, r2=r2*sc, center=true, $fn=sides);
|
cylinder(h=l, r1=r1*sc, r2=r2*sc, center=true, $fn=sides);
|
||||||
} else {
|
} else {
|
||||||
vang = atan2(l, r1-r2)/2;
|
vang = atan2(l, r1-r2)/2;
|
||||||
|
@ -524,8 +524,8 @@ module cyl(
|
||||||
chang2 = 90-first_defined([chamfang2, chamfang, 90-vang]);
|
chang2 = 90-first_defined([chamfang2, chamfang, 90-vang]);
|
||||||
cham1 = first_defined([chamfer1, chamfer]) * (from_end? 1 : tan(chang1));
|
cham1 = first_defined([chamfer1, chamfer]) * (from_end? 1 : tan(chang1));
|
||||||
cham2 = first_defined([chamfer2, chamfer]) * (from_end? 1 : tan(chang2));
|
cham2 = first_defined([chamfer2, chamfer]) * (from_end? 1 : tan(chang2));
|
||||||
fil1 = first_defined([fillet1, fillet]);
|
fil1 = first_defined([rounding1, rounding]);
|
||||||
fil2 = first_defined([fillet2, fillet]);
|
fil2 = first_defined([rounding2, rounding]);
|
||||||
if (chamfer != undef) {
|
if (chamfer != undef) {
|
||||||
assert(chamfer <= r1, "chamfer is larger than the r1 radius of the cylinder.");
|
assert(chamfer <= r1, "chamfer is larger than the r1 radius of the cylinder.");
|
||||||
assert(chamfer <= r2, "chamfer is larger than the r2 radius of the cylinder.");
|
assert(chamfer <= r2, "chamfer is larger than the r2 radius of the cylinder.");
|
||||||
|
@ -539,18 +539,18 @@ module cyl(
|
||||||
assert(cham2 <= r2, "chamfer2 is larger than the r2 radius of the cylinder.");
|
assert(cham2 <= r2, "chamfer2 is larger than the r2 radius of the cylinder.");
|
||||||
assert(cham2 <= l/2, "chamfer2 is larger than half the length of the cylinder.");
|
assert(cham2 <= l/2, "chamfer2 is larger than half the length of the cylinder.");
|
||||||
}
|
}
|
||||||
if (fillet != undef) {
|
if (rounding != undef) {
|
||||||
assert(fillet <= r1, "fillet is larger than the r1 radius of the cylinder.");
|
assert(rounding <= r1, "rounding is larger than the r1 radius of the cylinder.");
|
||||||
assert(fillet <= r2, "fillet is larger than the r2 radius of the cylinder.");
|
assert(rounding <= r2, "rounding is larger than the r2 radius of the cylinder.");
|
||||||
assert(fillet <= l/2, "fillet is larger than half the length of the cylinder.");
|
assert(rounding <= l/2, "rounding is larger than half the length of the cylinder.");
|
||||||
}
|
}
|
||||||
if (fil1 != undef) {
|
if (fil1 != undef) {
|
||||||
assert(fil1 <= r1, "fillet1 is larger than the r1 radius of the cylinder.");
|
assert(fil1 <= r1, "rounding1 is larger than the r1 radius of the cylinder.");
|
||||||
assert(fil1 <= l/2, "fillet1 is larger than half the length of the cylinder.");
|
assert(fil1 <= l/2, "rounding1 is larger than half the length of the cylinder.");
|
||||||
}
|
}
|
||||||
if (fil2 != undef) {
|
if (fil2 != undef) {
|
||||||
assert(fil2 <= r2, "fillet2 is larger than the r1 radius of the cylinder.");
|
assert(fil2 <= r2, "rounding2 is larger than the r1 radius of the cylinder.");
|
||||||
assert(fil2 <= l/2, "fillet2 is larger than half the length of the cylinder.");
|
assert(fil2 <= l/2, "rounding2 is larger than half the length of the cylinder.");
|
||||||
}
|
}
|
||||||
|
|
||||||
dy1 = first_defined([cham1, fil1, 0]);
|
dy1 = first_defined([cham1, fil1, 0]);
|
||||||
|
|
|
@ -2120,7 +2120,7 @@ module extrude_arc(arc=90, sa=0, r=undef, d=undef, orient=ORIENT_Z, anchor=CENTE
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// r = Radius to round all concave and convex corners to.
|
// r = Radius to round all concave and convex corners to.
|
||||||
// or = Radius to round only outside (convex) corners to. Use instead of `r`.
|
// or = Radius to round only outside (convex) corners to. Use instead of `r`.
|
||||||
// ir = Radius to round/fillet only inside (concave) corners to. Use instead of `r`.
|
// ir = Radius to round only inside (concave) corners to. Use instead of `r`.
|
||||||
// Examples(2D):
|
// Examples(2D):
|
||||||
// round2d(r=10) {square([40,100], center=true); square([100,40], center=true);}
|
// round2d(r=10) {square([40,100], center=true); square([100,40], center=true);}
|
||||||
// round2d(or=10) {square([40,100], center=true); square([100,40], center=true);}
|
// round2d(or=10) {square([40,100], center=true); square([100,40], center=true);}
|
||||||
|
@ -2142,9 +2142,9 @@ module round2d(r, or, ir)
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// thickness = Thickness of the shell. Positive to expand outward, negative to shrink inward, or a two-element list to do both.
|
// thickness = Thickness of the shell. Positive to expand outward, negative to shrink inward, or a two-element list to do both.
|
||||||
// or = Radius to round convex corners/pointy bits on the outside of the shell.
|
// or = Radius to round convex corners/pointy bits on the outside of the shell.
|
||||||
// ir = Radius to round/fillet concave corners on the outside of the shell.
|
// ir = Radius to round concave corners on the outside of the shell.
|
||||||
// round = Radius to round convex corners/pointy bits on the inside of the shell.
|
// round = Radius to round convex corners/pointy bits on the inside of the shell.
|
||||||
// fill = Radius to round/fillet concave corners on the inside of the shell.
|
// fill = Radius to round concave corners on the inside of the shell.
|
||||||
// Examples(2D):
|
// Examples(2D):
|
||||||
// shell2d(10) {square([40,100], center=true); square([100,40], center=true);}
|
// shell2d(10) {square([40,100], center=true); square([100,40], center=true);}
|
||||||
// shell2d(-10) {square([40,100], center=true); square([100,40], center=true);}
|
// shell2d(-10) {square([40,100], center=true); square([100,40], center=true);}
|
||||||
|
|
14
wiring.scad
14
wiring.scad
|
@ -95,20 +95,20 @@ function hex_offsets(n, d, lev=0, arr=[]) =
|
||||||
// Module: wiring()
|
// Module: wiring()
|
||||||
// Description:
|
// Description:
|
||||||
// Returns a 3D object representing a bundle of wires that follow a given path,
|
// Returns a 3D object representing a bundle of wires that follow a given path,
|
||||||
// with the corners filleted to a given radius. There are 17 base wire colors.
|
// with the corners rounded to a given radius. There are 17 base wire colors.
|
||||||
// If you have more than 17 wires, colors will get re-used.
|
// If you have more than 17 wires, colors will get re-used.
|
||||||
// Usage:
|
// Usage:
|
||||||
// wiring(path, wires, [wirediam], [fillet], [wirenum], [bezsteps]);
|
// wiring(path, wires, [wirediam], [rounding], [wirenum], [bezsteps]);
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// path = The 3D polyline path that the wire bundle should follow.
|
// path = The 3D polyline path that the wire bundle should follow.
|
||||||
// wires = The number of wires in the wiring bundle.
|
// wires = The number of wires in the wiring bundle.
|
||||||
// wirediam = The diameter of each wire in the bundle.
|
// wirediam = The diameter of each wire in the bundle.
|
||||||
// fillet = The radius that the path corners will be filleted to.
|
// rounding = The radius that the path corners will be rounded to.
|
||||||
// wirenum = The first wire's offset into the color table.
|
// wirenum = The first wire's offset into the color table.
|
||||||
// bezsteps = The corner fillets in the path will be converted into this number of segments.
|
// bezsteps = The corner roundings in the path will be converted into this number of segments.
|
||||||
// Example:
|
// Example:
|
||||||
// wiring([[50,0,-50], [50,50,-50], [0,50,-50], [0,0,-50], [0,0,0]], fillet=10, wires=13);
|
// wiring([[50,0,-50], [50,50,-50], [0,50,-50], [0,0,-50], [0,0,0]], rounding=10, wires=13);
|
||||||
module wiring(path, wires, wirediam=2, fillet=10, wirenum=0, bezsteps=12) {
|
module wiring(path, wires, wirediam=2, rounding=10, wirenum=0, bezsteps=12) {
|
||||||
colors = [
|
colors = [
|
||||||
[0.2, 0.2, 0.2], [1.0, 0.2, 0.2], [0.0, 0.8, 0.0], [1.0, 1.0, 0.2],
|
[0.2, 0.2, 0.2], [1.0, 0.2, 0.2], [0.0, 0.8, 0.0], [1.0, 1.0, 0.2],
|
||||||
[0.3, 0.3, 1.0], [1.0, 1.0, 1.0], [0.7, 0.5, 0.0], [0.5, 0.5, 0.5],
|
[0.3, 0.3, 1.0], [1.0, 1.0, 1.0], [0.7, 0.5, 0.0], [0.5, 0.5, 0.5],
|
||||||
|
@ -117,7 +117,7 @@ module wiring(path, wires, wirediam=2, fillet=10, wirenum=0, bezsteps=12) {
|
||||||
[0.6, 0.6, 1.0],
|
[0.6, 0.6, 1.0],
|
||||||
];
|
];
|
||||||
offsets = hex_offsets(wires, wirediam);
|
offsets = hex_offsets(wires, wirediam);
|
||||||
bezpath = fillet_path(path, fillet);
|
bezpath = fillet_path(path, rounding);
|
||||||
poly = simplify3d_path(path3d(bezier_polyline(bezpath, bezsteps)));
|
poly = simplify3d_path(path3d(bezier_polyline(bezpath, bezsteps)));
|
||||||
n = max(segs(wirediam), 8);
|
n = max(segs(wirediam), 8);
|
||||||
r = wirediam/2;
|
r = wirediam/2;
|
||||||
|
|
Loading…
Reference in a new issue