fix nut beveling, $slop handling for screw_hole, make default counterbore=true

This commit is contained in:
Adrian Mariano 2022-10-13 17:20:43 -04:00
parent 68a26db513
commit af36385835
2 changed files with 217 additions and 146 deletions

View file

@ -523,12 +523,17 @@ module screw(spec, head, drive, thread, drive_size,
_counterbore = _counterbore==true ? struct_val(tempspec,"head_height")
: _counterbore==false ? undef
: _counterbore;
head = struct_val(tempspec,"head");
headless = head=="none";
flathead = starts_with(head,"flat");
reset_headsize = _internal && flathead ? struct_val(tempspec,"head_size_sharp") : undef;
spec=_struct_reset(tempspec,[
["length", l],
["threads_oversize", u_mul(-1,shaft_undersize)],
["head_oversize", u_mul(-1,head_undersize)],
["counterbore", _counterbore],
["thread_len", thread_len]
["thread_len", thread_len],
["head_size", reset_headsize],
]);
dummy = _validate_screw_spec(spec);
$screw_spec = spec;
@ -537,10 +542,6 @@ module screw(spec, head, drive, thread, drive_size,
nominal_diam = _nominal_diam(spec);
d_major = pitch==0 ? nominal_diam : mean(struct_val(threadspec, "d_major"));
length = struct_val(spec,"length");
head = struct_val(spec,"head");
headless = head=="none";
flathead = starts_with(head,"flat");
counterbore = default(struct_val(spec,"counterbore"),0);
user_thread_len = struct_val(spec,"thread_len");
dummyC = assert(in_list(atype,["shaft","head","shank","threads","screw","shoulder"]),str("Unknown anchor type: \"",atype,"\""))
@ -630,14 +631,14 @@ module screw(spec, head, drive, thread, drive_size,
up(offset)
difference(){
union(){
screw_head(spec,details,counterbore=counterbore,flat_height=flat_height);
screw_head(spec,details,counterbore=counterbore,flat_height=flat_height,oversize=_internal?4*get_slop():0);
if (_shoulder_len>0)
up(eps_shoulder-flat_height)
cyl(d=_shoulder_diam, h=_shoulder_len+eps_shoulder, anchor=TOP, $fn=sides, chamfer1=details ? _shoulder_diam/30:0);
cyl(d=_shoulder_diam+(_internal?4*get_slop():0), h=_shoulder_len+eps_shoulder, anchor=TOP, $fn=sides, chamfer1=details ? _shoulder_diam/30:0);
if (shank_len>0 || pitch==0){
L = pitch==0 ? length - (_shoulder_len==0?flat_height:0) : shank_len;
down(_shoulder_len+flat_height-eps_shank)
cyl(d=d_major, h=L+eps_shank, anchor=TOP, $fn=sides);
cyl(d=d_major+(_internal?4*get_slop():0), h=L+eps_shank, anchor=TOP, $fn=sides);
}
if (thread_len>0 && pitch>0)
down(_shoulder_len+flat_height+shank_len-eps_thread)
@ -678,9 +679,9 @@ module screw(spec, head, drive, thread, drive_size,
// and "H14" for "coarse". These designations will also work, but only for metric holes. You can also set tolerance to 0 or "none" to produce holes at the nominal size.
// .
// The counterbore parameter adds a cylindrical clearance hole above the screw shaft. For flat heads it extends above the flathead and for other screw types it
// replaces the head with a cylinder large enough for the head to fit. For a flat head you must specify the length of the counterbore. For other heads you can
// replaces the head with a cylinder large enough in diameter for the head to fit. For a flat head you must specify the length of the counterbore. For other heads you can
// set counterbore to true and it will be sized to match the head height. The counterbore will extend 0.01 above the TOP of the hole mask to ensure no
// problems with differences.
// problems with differences. Note that the counterbore defaults to true for non-flathead screws. If you want the actual head shape to appear, set counterbore to zero.
// .
// Anchoring for screw_hole() is the same as anchoring for {{screw()}}, with all the same anchor types and named anchors. If you specify a counterbore it is treated as
// the "head", or in the case of flat heads, it becomes part of the head.
@ -693,7 +694,7 @@ module screw(spec, head, drive, thread, drive_size,
// oversize_hole = amount to increase diameter of the hole.
// oversize_head = amount to increase diameter of head.
// length / l= length of screw (in mm)
// counterbore = set to length of counterbore, or true to make a counterbore equal to head height. Default: no counterbore
// counterbore = set to length of counterbore, or true to make a counterbore equal to head height. Default: false for flat heads and headless, true otherwise
// tolerance = threading or clearance hole tolerance. For internal threads, detrmines actual thread geometry based on nominal sizing. See [tolerance](#subsection-tolerance). Default is "2B" for UTS and 6H for ISO. For clearance holes, determines how much clearance to add. Default is "normal".
// $slop = add extra gap to account for printer overextrusion. Default: 0
// atype = anchor type, one of "screw", "head", "shaft", "threads", "shank"
@ -740,14 +741,14 @@ module screw(spec, head, drive, thread, drive_size,
// attach(FRONT)
// screw_hole("M16,15",anchor=TOP,thread=true);
module screw_hole(spec, head, thread, oversize, hole_oversize, head_oversize,
length, l, thread_len, tolerance=undef, counterbore=0,
length, l, thread_len, tolerance=undef, counterbore,
atype="screw",anchor=BOTTOM,spin=0, orient=UP)
{
// Force flatheads to sharp for proper countersink shape
head = is_def(head) && starts_with(head,"flat") ? str(head," sharp")
: head;
screwspec = _get_spec(spec, "screw_info", "screw_hole",
thread=thread, head=head);
checkhead = struct_val(screwspec,"head");
default_counterbore = checkhead=="none" || starts_with(checkhead,"flat") ? 0 : true;
counterbore = default(counterbore, default_counterbore);
dummy = _validate_screw_spec(screwspec);
threaded = thread==true || (is_finite(thread) && thread>0) || (is_undef(thread) && struct_val(screwspec,"pitch")>0);
if (threaded || is_def(oversize) || is_def(hole_oversize) || tolerance==0 || tolerance=="none") {
@ -1282,7 +1283,7 @@ function _parse_drive(drive=undef, drive_size=undef) =
// Module: screw_head()
// Usage:
// screw_head(screw_info, [details],[counterbore],[flat_height])
// screw_head(screw_info, [details],[counterbore],[flat_height],[oversize])
// Description:
// Draws the screw head described by the data structure `screw_info`, which
// should have the fields produced by {{screw_info()}}. See that function for
@ -1295,9 +1296,9 @@ function _parse_drive(drive=undef, drive_size=undef) =
// counterbore = counterbore height. Default: no counterbore
// flat_height = height of flat head
function screw_head(screw_info,details,counterbore,flat_height) = no_function("screw_head");
module screw_head(screw_info,details=false, counterbore=0,flat_height) {
module screw_head(screw_info,details=false, counterbore=0,flat_height,oversize=0) {
no_children($children);
head_oversize = struct_val(screw_info, "head_oversize",0);
head_oversize = struct_val(screw_info, "head_oversize",0) + oversize;
head = struct_val(screw_info, "head");
head_size = struct_val(screw_info, "head_size",0) + head_oversize;
head_height = struct_val(screw_info, "head_height");
@ -1394,7 +1395,13 @@ module screw_head(screw_info,details=false, counterbore=0,flat_height) {
// nutwidth = width of nut (overrides table values)
// thread = thread type or specification. See [screw pitch](#subsection-standard-screw-pitch). Default: "coarse"
// hole_oversize = amount to increase hole diameter. Default: 0
// bevel = bevel the nut. Default: false
// bevel = if true, bevel the outside of the nut.
// bevel1 = if true, bevel the outside of the nut bottom.
// bevel2 = if true, bevel the outside of the nut top.
// bevang = set the angle for the outside nut bevel. Default: 15
// ibevel = if true, bevel the inside (the hole). Default: true
// ibevel1 = if true bevel the inside, bottom end.
// ibevel2 = if true bevel the inside, top end.
// tolerance = nut tolerance. Determines actual nut thread geometry based on nominal sizing. See [tolerance](#subsection-tolerance). Default is "2B" for UTS and "6H" for ISO.
// $slop = extra space left to account for printing over-extrusion. Default: 0
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
@ -1436,11 +1443,14 @@ module screw_head(screw_info,details=false, counterbore=0,flat_height) {
// mark(2) nut("1/4-20", thickness=8, nutwidth=0.5*INCH,tolerance="2B");
// mark(3) nut("1/4-20", thickness=8, nutwidth=0.5*INCH,tolerance="3B");
// }
// Example: Threadless nut
// nut("#8", thread="none");
function nut(spec, shape, thickness, nutwidth, thread, tolerance, hole_oversize,
bevel=true, anchor=BOTTOM, spin=0, orient=UP, oversize=0) = no_function("nut");
bevel,bevel1,bevel2,bevang=15,ibevel,ibevel1,ibevel2, anchor=BOTTOM, spin=0, orient=UP, oversize=0)
= no_function("nut");
module nut(spec, shape, thickness, nutwidth, thread, tolerance, hole_oversize,
bevel=true, anchor=BOTTOM, spin=0, orient=UP, oversize=0)
bevel,bevel1,bevel2,bevang=15,ibevel,ibevel1,ibevel2, anchor=BOTTOM, spin=0, orient=UP, oversize=0)
{
dummyA = assert(is_undef(nutwidth) || (is_num(nutwidth) && nutwidth>0));
@ -1459,13 +1469,15 @@ module nut(spec, shape, thickness, nutwidth, thread, tolerance, hole_oversize,
thickness = struct_val(spec, "thickness");
threaded_nut(
nutwidth=nutwidth,
id=[mean(struct_val(threadspec, "d_minor")),
id=pitch==0 ? _nominal_diam(spec)
: [mean(struct_val(threadspec, "d_minor")),
mean(struct_val(threadspec, "d_pitch")),
mean(struct_val(threadspec, "d_major"))],
pitch = struct_val(threadspec, "pitch"),
pitch = pitch,
h=thickness,
shape=shape,
bevel=bevel,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,bevang=bevang,
ibevel=ibevel,ibevel1=ibevel1,ibevel2=ibevel2,
anchor=anchor,spin=spin,orient=orient) children();
}
@ -1751,7 +1763,7 @@ function nut_info(spec, shape, thickness, thread, hole_oversize=0, width, _origi
in_list(_downcase_if_str(thickness),["thin","normal","thick","undersized","din"]),
"thickness must be a positive number of one of \"thin\", \"thick\", \"normal\", \"undersized\", or \"DIN\"")
let(
shape = downcase(default(shape,"hex")),
shape = _downcase_if_str(default(shape,"hex")),
thickness = _downcase_if_str(default(thickness, "normal"))
)
assert(is_string(spec), str("Nut specification must be a string ",spec))

View file

@ -13,7 +13,7 @@
// Module: threaded_rod()
// Usage:
// threaded_rod(d, l, pitch, [internal=], ...) [ATTACHMENTS];
// threaded_rod(d, l|length, pitch, [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs a standard ISO (metric) or UTS (English) threaded rod. These threads are close to triangular,
// with a 60 degree thread angle. You can give the outer diameter and get the "basic form" or you can
@ -22,7 +22,7 @@
// using the specification parameters.
// Arguments:
// d = Outer diameter of threaded rod, or a triplet of [d_min, d_pitch, d_major].
// l = length of threaded rod.
// l / length = length of threaded rod.
// pitch = Length between threads.
// ---
// left_handed = if true, create left-handed threads. Default = false
@ -74,7 +74,7 @@ module threaded_rod(
left_handed=false,
bevel,bevel1,bevel2,starts=1,
internal=false,
d1, d2,
d1, d2, length,
higbee, higbee1, higbee2,
anchor, spin, orient
) {
@ -114,7 +114,7 @@ module threaded_rod(
profile=profile,starts=starts,
left_handed=left_handed,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
internal=internal,
internal=internal, length=length,
higbee=higbee,
higbee1=higbee1,
higbee2=higbee2,
@ -128,21 +128,25 @@ module threaded_rod(
// Module: threaded_nut()
// Usage:
// threaded_nut(nutwidth, id, h, pitch,...) [ATTACHMENTS];
// threaded_nut(nutwidth, id, h|height|thickness, pitch,...) [ATTACHMENTS];
// Description:
// Constructs a hex nut or square nut for an ISO (metric) or UTS (English) threaded rod.
// Arguments:
// nutwidth = flat to flat width of nut
// id = diameter of threaded rod to screw onto.
// h = height/thickness of nut.
// pitch = Length between threads.
// h / height / thickness = height/thickness of nut.
// pitch = Distance between threads, or zero for no threads.
// ---
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
// left_handed = if true, create left-handed threads. Default = false
// starts = The number of lead starts. Default: 1
// bevel = if true, bevel the thread ends. Default: false
// bevel1 = if true bevel the bottom end.
// bevel2 = if true bevel the top end.
// bevel = if true, bevel the outside of the nut.
// bevel1 = if true, bevel the outside of the nut bottom.
// bevel2 = if true, bevel the outside of the nut top.
// bevang = set the angle for the outside nut bevel. Default: 15
// ibevel = if true, bevel the inside (the hole). Default: true
// ibevel1 = if true bevel the inside, bottom end.
// ibevel2 = if true bevel the inside, top end.
// 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`
@ -152,16 +156,18 @@ module threaded_rod(
// threaded_nut(nutwidth=16, id=8, h=8, pitch=1.25, left_handed=true, bevel=true, $slop=0.1, $fa=1, $fs=1);
function threaded_nut(
nutwidth, id, h,
pitch, starts=1, shape, left_handed=false, bevel, bevel1, bevel2, id1,id2,
pitch, starts=1, shape="hex", left_handed=false, bevel, bevel1, bevel2, id1,id2,
ibevel1, ibevel2, ibevel, bevang=15, thickness, height,
anchor, spin, orient
)=no_function("threaded_nut");
module threaded_nut(
nutwidth, id, h,
pitch, starts=1, shape="hex", left_handed=false, bevel, bevel1, bevel2, id1,id2,
ibevel1, ibevel2, ibevel, bevang=15, thickness, height,
anchor, spin, orient
) {
dummy1=
assert(all_positive(pitch), "Nut pitch must be positive")
assert(all_nonnegative(pitch), "Nut pitch must be nonnegative")
assert(all_positive(id), "Nut inner diameter must be positive")
assert(all_positive(h),"Nut thickness must be positive");
basic = is_num(id) || is_undef(id) || is_def(id1) || is_def(id2);
@ -191,6 +197,8 @@ module threaded_nut(
profile=profile,starts=starts,shape=shape,
left_handed=left_handed,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
ibevel1=ibevel1, ibevel2=ibevel2, ibevel=ibevel,
height=height, thickness=thickness, bevang=bevang,
anchor=anchor, spin=spin,
orient=orient
) children();
@ -201,7 +209,7 @@ module threaded_nut(
// Module: trapezoidal_threaded_rod()
// Usage:
// trapezoidal_threaded_rod(d, l, pitch, [thread_angle], [thread_depth], [internal=], ...) [ATTACHMENTS];
// trapezoidal_threaded_rod(d, l|length, pitch, [thread_angle], [thread_depth], [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs a threaded rod with a symmetric trapezoidal thread. Trapezoidal threads are used for lead screws because
// they are one of the strongest symmetric profiles. This tooth shape is stronger than a similarly
@ -237,7 +245,7 @@ module threaded_nut(
// }
// Arguments:
// d = Outer diameter of threaded rod.
// l = Length of threaded rod.
// l / length = Length of threaded rod.
// pitch = Thread spacing.
// thread_angle = Angle between two thread faces. Default: 30
// thread_depth = Depth of threads. Default: pitch/2
@ -253,7 +261,6 @@ module threaded_nut(
// higbee = Length to taper thread ends over. Default: 0 (No higbee thread tapering)
// higbee1 = Length to taper bottom thread end over.
// higbee2 = Length to taper top thread end over.
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=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`
@ -271,7 +278,7 @@ module threaded_nut(
// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=90, left_handed=true, $fa=2, $fs=2);
// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=90, left_handed=true, starts=4, $fa=2, $fs=2);
// trapezoidal_threaded_rod(d=16, l=40, pitch=2, thread_angle=60);
// trapezoidal_threaded_rod(d=25, l=40, pitch=10, thread_depth=8/3, thread_angle=100, starts=4, center=false, $fa=2, $fs=2);
// trapezoidal_threaded_rod(d=25, l=40, pitch=10, thread_depth=8/3, thread_angle=100, starts=4, anchor=BOT, $fa=2, $fs=2);
// trapezoidal_threaded_rod(d=50, l=35, pitch=8, thread_angle=60, starts=11, higbee=10,$fn=120);
// Example(Med): Using as a Mask to Make Internal Threads
// bottom_half() difference() {
@ -284,10 +291,10 @@ function trapezoidal_threaded_rod(
thread_depth=undef,
left_handed=false,
bevel,bevel1,bevel2,
starts=1,
starts=1, length,
internal=false,
higbee, higbee1, higbee2,d1,d2,
center, anchor, spin, orient
anchor, spin, orient
) = no_function("trapezoidal_threaded_rod");
module trapezoidal_threaded_rod(
d, l, pitch,
@ -295,10 +302,10 @@ module trapezoidal_threaded_rod(
thread_depth=undef,
left_handed=false,
bevel,bevel1,bevel2,
starts=1,
starts=1, length,
internal=false,
higbee, higbee1, higbee2,d1,d2,
center, anchor, spin, orient
anchor, spin, orient
) {
dummy0 = assert(all_positive(pitch));
dummy1 = assert(thread_angle>=0 && thread_angle<180);
@ -316,14 +323,14 @@ module trapezoidal_threaded_rod(
];
generic_threaded_rod(d=d,l=l,pitch=pitch,profile=profile,
left_handed=left_handed,bevel=bevel,bevel1=bevel1,bevel2=bevel2,starts=starts,internal=internal,d1=d1,d2=d2,
higbee=higbee,higbee1=higbee1,higbee2=higbee2,center=center,anchor=anchor,spin=spin,orient=orient)
higbee=higbee,higbee1=higbee1,higbee2=higbee2,anchor=anchor,spin=spin,orient=orient,length=length)
children();
}
// Module: trapezoidal_threaded_nut()
// Usage:
// trapezoidal_threaded_nut(nutwidth, id, h, pitch, [thread_angle], [thread_depth], ...) [ATTACHMENTS];
// trapezoidal_threaded_nut(nutwidth, id, h|height|thickness, pitch, [thread_angle], [thread_depth], ...) [ATTACHMENTS];
// Description:
// Constructs a hex nut or square nut for a symmetric trapzoidal threaded rod.
// By default produces the nominal dimensions
@ -332,7 +339,7 @@ module trapezoidal_threaded_rod(
// Arguments:
// nutwidth = flat to flat width of nut
// id = diameter of threaded rod to screw onto.
// h = height/thickness of nut.
// h / height / thickness = height/thickness of nut.
// pitch = Thread spacing.
// thread_angle = Angle between two thread faces. Default: 30
// thread_depth = Depth of the threads. Default: pitch/2
@ -340,9 +347,13 @@ module trapezoidal_threaded_rod(
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
// left_handed = if true, create left-handed threads. Default = false
// starts = The number of lead starts. Default = 1
// bevel = if true, bevel the thread ends. Default: false
// bevel1 = if true bevel the bottom end.
// bevel2 = if true bevel the top end.
// bevel = if true, bevel the outside of the nut.
// bevel1 = if true, bevel the outside of the nut bottom.
// bevel2 = if true, bevel the outside of the nut top.
// bevang = set the angle for the outside nut bevel. Default: 15
// ibevel = if true, bevel the inside (the hole). Default: true
// ibevel1 = if true bevel the inside, bottom end.
// ibevel2 = if true bevel the inside, top end.
// 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`
@ -352,16 +363,21 @@ module trapezoidal_threaded_rod(
// trapezoidal_threaded_nut(nutwidth=16, id=8, h=8, pitch=2, bevel=true, $slop=0.05, anchor=UP);
// trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=2, $slop=0.1, left_handed=true);
// trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=2, starts=3, $fa=1, $fs=1, $slop=0.15);
// trapezoidal_threaded_nut(nutwidth=17.4, id=10, h=10, pitch=0, $slop=0.2); // No threads
function trapezoidal_threaded_nut(
d, l, pitch,
nutwidth,
id,
h,
pitch,
thread_angle=30,
thread_depth=undef, shape,
thread_depth, shape="hex",
left_handed=false,
bevel,bevel1,bevel2,
starts=1,
internal=false,
higbee, higbee1, higbee2,d1,d2,
center, anchor, spin, orient
bevel,bevel1,bevel2,bevang=15,
ibevel1,ibevel2,ibevel,
thickness,height,
id1,id2,
anchor, spin, orient
) = no_function("trapezoidal_threaded_nut");
module trapezoidal_threaded_nut(
nutwidth,
@ -372,14 +388,16 @@ module trapezoidal_threaded_nut(
thread_depth, shape="hex",
left_handed=false,
starts=1,
bevel,bevel1,bevel2,
bevel,bevel1,bevel2,bevang=15,
ibevel1,ibevel2,ibevel,
thickness,height,
id1,id2,
anchor, spin, orient
) {
dummy1 = assert(pitch>0 && thread_angle>=0 && thread_angle<180);
dummy1 = assert(is_num(pitch) && pitch>=0 && thread_angle>=0 && thread_angle<180);
depth = first_defined([thread_depth, pitch/2]);
pa_delta = 0.5*depth*tan(thread_angle/2) / pitch;
dummy2 = assert(pa_delta<1/4, "Specified thread geometry is impossible");
dummy2 = assert(pitch==0 || pa_delta<1/4, "Specified thread geometry is impossible");
rr1 = -depth/pitch;
z1 = 1/4-pa_delta;
z2 = 1/4+pa_delta;
@ -391,6 +409,7 @@ module trapezoidal_threaded_nut(
];
generic_threaded_nut(nutwidth=nutwidth,id=id,h=h,pitch=pitch,profile=profile,id1=id1,id2=id2,
shape=shape,left_handed=left_handed,bevel=bevel,bevel1=bevel1,bevel2=bevel2,starts=starts,
ibevel=ibevel,ibevel1=ibevel1,ibevel2=ibevel2,bevang=bevang,height=height,thickness=thickness,
anchor=anchor,spin=spin,orient=orient)
children();
}
@ -398,13 +417,13 @@ module trapezoidal_threaded_nut(
// Module: acme_threaded_rod()
// Usage:
// acme_threaded_rod(d, l, tpi|pitch=, [internal=], ...) [ATTACHMENTS];
// acme_threaded_rod(d, l|length, tpi|pitch=, [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs an ACME trapezoidal threaded screw rod. This form has a 29 degree thread angle with a
// symmetric trapezoidal thread.
// Arguments:
// d = Outer diameter of threaded rod.
// l = length of threaded rod.
// l / length = length of threaded rod.
// tpi = threads per inch.
// ---
// pitch = thread spacing (alternative to tpi)
@ -432,7 +451,7 @@ function acme_threaded_rod(
starts=1,
left_handed=false,
bevel,bevel1,bevel2,
internal=false,
internal=false, length,
higbee, higbee1, higbee2,
anchor, spin, orient
) = no_function("acme_threaded_rod");
@ -441,7 +460,7 @@ module acme_threaded_rod(
starts=1,
left_handed=false,
bevel,bevel1,bevel2,
internal=false,
internal=false, length,
higbee, higbee1, higbee2,
anchor, spin, orient
) {
@ -454,7 +473,7 @@ module acme_threaded_rod(
starts=starts,
left_handed=left_handed,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
internal=internal,
internal=internal, length=length,
anchor=anchor,
spin=spin,
orient=orient
@ -465,22 +484,26 @@ module acme_threaded_rod(
// Module: acme_threaded_nut()
// Usage:
// acme_threaded_nut(nutwidth, id, h, tpi|pitch=, [shape=], ...) [ATTACHMENTS];
// acme_threaded_nut(nutwidth, id, h|height|thickness, tpi|pitch=, [shape=], ...) [ATTACHMENTS];
// Description:
// Constructs a hexagonal or square nut for an ACME threaded screw rod.
// Arguments:
// nutwidth = flat to flat width of nut.
// id = diameter of threaded rod to screw onto.
// h = height/thickness of nut.
// h / height / thickness = height/thickness of nut.
// tpi = threads per inch
// ---
// pitch = Thread spacing (alternative to tpi)
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
// left_handed = if true, create left-handed threads. Default = false
// starts = Number of lead starts. Default: 1
// bevel = if true, bevel the thread ends. Default: false
// bevel1 = if true bevel the bottom end.
// bevel2 = if true bevel the top end.
// bevel = if true, bevel the outside of the nut.
// bevel1 = if true, bevel the outside of the nut bottom.
// bevel2 = if true, bevel the outside of the nut top.
// bevang = set the angle for the outside nut bevel. Default: 15
// ibevel = if true, bevel the inside (the hole). Default: true
// ibevel1 = if true bevel the inside, bottom end.
// ibevel2 = if true bevel the inside, top end.
// 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`
@ -491,26 +514,32 @@ module acme_threaded_rod(
function acme_threaded_nut(
nutwidth, id, h, tpi, pitch,
starts=1,
left_handed=false,shape,
bevel,bevel1,bevel2,
left_handed=false,shape="hex",
bevel,bevel1,bevel2,bevang=15,
ibevel,ibevel1,ibevel2,
height,thickness,
anchor, spin, orient
) = no_function("acme_threaded_nut");
module acme_threaded_nut(
nutwidth, id, h, tpi, pitch,
starts=1,
left_handed=false,shape="hex",
bevel,bevel1,bevel2,
bevel,bevel1,bevel2,bevang=15,
ibevel,ibevel1,ibevel2,
height,thickness,
anchor, spin, orient
) {
dummy = assert(num_defined([pitch,tpi])==1,"Must give exactly one of pitch and tpi");
pitch = is_undef(pitch) ? INCH/tpi : pitch;
dummy2=assert(is_num(pitch) && pitch>0);
dummy2=assert(is_num(pitch) && pitch>=0);
trapezoidal_threaded_nut(
nutwidth=nutwidth, id=id, h=h, pitch=pitch,
thread_depth = pitch/2,
thread_angle=29,shape=shape,
left_handed=left_handed,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
ibevel=ibevel,ibevel1=ibevel1,ibevel2=ibevel2,
height=height,thickness=thickness,
starts=starts,
anchor=anchor,
spin=spin,
@ -644,14 +673,14 @@ module npt_threaded_rod(
// Module: buttress_threaded_rod()
// Usage:
// buttress_threaded_rod(d, l, pitch, [internal=], ...) [ATTACHMENTS];
// buttress_threaded_rod(d, l|length, pitch, [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs a simple buttress threaded rod with a 45 degree angle. The buttress thread or sawtooth thread has low friction and high loading
// in one direction at the cost of higher friction and inferior loading in the other direction. Buttress threads are sometimes used on
// vises, which are loaded only in one direction.
// Arguments:
// d = Outer diameter of threaded rod.
// l = length of threaded rod.
// l / length = length of threaded rod.
// pitch = Thread spacing.
// ---
// left_handed = if true, create left-handed threads. Default = false
@ -676,25 +705,25 @@ module npt_threaded_rod(
// buttress_threaded_rod(d=10, l=20, pitch=1.25, left_handed=true, $fa=1, $fs=1);
// buttress_threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1);
function buttress_threaded_rod(
d=10, l=100, pitch=2,
d, l, pitch,
left_handed=false,
bevel,bevel1,bevel2,
internal=false,
higbee=0,
higbee1,
higbee2,
d1,d2,starts,
d1,d2,starts=1,length,
anchor, spin, orient
) = no_function("buttress_threaded_rod");
module buttress_threaded_rod(
d=10, l=100, pitch=2,
d, l, pitch,
left_handed=false,
bevel,bevel1,bevel2,
internal=false,
higbee=0,
higbee1,
higbee2,
d1,d2,starts=1,
d1,d2,starts=1,length,
anchor, spin, orient
) {
depth = pitch * 3/4;
@ -715,7 +744,7 @@ module buttress_threaded_rod(
higbee1=higbee1,
higbee2=higbee2,
d1=d1,d2=d2,
anchor=anchor,
anchor=anchor,length=length,
spin=spin,starts=starts,
orient=orient
) children();
@ -725,7 +754,7 @@ module buttress_threaded_rod(
// Module: buttress_threaded_nut()
// Usage:
// buttress_threaded_nut(nutwidth, id, h, pitch, ...) [ATTACHMENTS];
// buttress_threaded_nut(nutwidth, id, h|height|thickness, pitch, ...) [ATTACHMENTS];
// Description:
// Constructs a hexagonal or square nut for a simple buttress threaded screw rod.
// Arguments:
@ -737,9 +766,13 @@ module buttress_threaded_rod(
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
// left_handed = if true, create left-handed threads. Default = false
// starts = The number of lead starts. Default: 1
// bevel = if true, bevel the thread ends. Default: false
// bevel1 = if true bevel the bottom end.
// bevel2 = if true bevel the top end.
// bevel = if true, bevel the outside of the nut.
// bevel1 = if true, bevel the outside of the nut bottom.
// bevel2 = if true, bevel the outside of the nut top.
// bevang = set the angle for the outside nut bevel. Default: 15
// ibevel = if true, bevel the inside (the hole). Default: true
// ibevel1 = if true bevel the inside, bottom end.
// ibevel2 = if true bevel the inside, top end.
// 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`
@ -747,15 +780,17 @@ module buttress_threaded_rod(
// Examples(Med):
// buttress_threaded_nut(nutwidth=16, id=8, h=8, pitch=1.25, left_handed=true, $slop=0.05, $fa=1, $fs=1);
function buttress_threaded_nut(
nutwidth=16, id=10, h=10,
pitch=2, shape, left_handed=false,
bevel,bevel1,bevel2,starts,
nutwidth, id, h,
pitch, shape="hex", left_handed=false,
bevel,bevel1,bevel2,bevang=15,starts=1,
ibevel,ibevel1,ibevel2,height,thickness,
anchor, spin, orient
) = no_function("buttress_threaded_nut");
module buttress_threaded_nut(
nutwidth=16, id=10, h=10,
pitch=2, shape="hex", left_handed=false,
bevel,bevel1,bevel2,starts=1,
nutwidth, id, h,
pitch, shape="hex", left_handed=false,
bevel,bevel1,bevel2,bevang=15,starts=1,
ibevel,ibevel1,ibevel2,height,thickness,
anchor, spin, orient
) {
depth = pitch * 3/4;
@ -772,8 +807,9 @@ module buttress_threaded_nut(
profile=profile,
shape=shape,
left_handed=left_handed,starts=starts,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
anchor=anchor, spin=spin,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,bevang=bevang,
ibevel=ibevel,ibevel1=ibevel1,ibevel2=ibevel2,
anchor=anchor, spin=spin, height=height, thickness=thickness,
orient=orient
) children();
}
@ -784,13 +820,13 @@ module buttress_threaded_nut(
// Module: square_threaded_rod()
// Usage:
// square_threaded_rod(d, l, pitch, [internal=], ...) [ATTACHMENTS];
// square_threaded_rod(d, l|length, pitch, [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs a square profile threaded screw rod. The greatest advantage of square threads is that they have the least friction and a much higher intrinsic efficiency than trapezoidal threads.
// They produce no radial load on the nut. However, square threads cannot carry as much load as trapezoidal threads.
// Arguments:
// d = Outer diameter of threaded rod.
// l = length of threaded rod.
// l / length = length of threaded rod.
// pitch = Thread spacing.
// ---
// left_handed = if true, create left-handed threads. Default = false
@ -830,7 +866,7 @@ module square_threaded_rod(
starts=1,
internal=false,
higbee=0, higbee1, higbee2,
d1,d2,
d1,d2,length,
anchor, spin, orient
) {
trapezoidal_threaded_rod(
@ -845,6 +881,7 @@ module square_threaded_rod(
higbee2=higbee2,
d1=d1,
d2=d2,
length=length,
anchor=anchor,
spin=spin,
orient=orient
@ -855,21 +892,25 @@ module square_threaded_rod(
// Module: square_threaded_nut()
// Usage:
// square_threaded_nut(nutwidth, id, h, pitch, ...) [ATTACHMENTS];
// square_threaded_nut(nutwidth, id, h|height|thickness, pitch, ...) [ATTACHMENTS];
// Description:
// Constructs a hexagonal or square nut for a square profile threaded screw rod.
// Arguments:
// nutwidth = diameter of the nut.
// id = diameter of threaded rod to screw onto.
// h = height/thickness of nut.
// h / height / thickness = height/thickness of nut.
// pitch = Length between threads.
// ---
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
// left_handed = if true, create left-handed threads. Default = false
// starts = The number of lead starts. Default = 1
// bevel = if true, bevel the thread ends. Default: false
// bevel1 = if true bevel the bottom end.
// bevel2 = if true bevel the top end.
// bevel = if true, bevel the outside of the nut.
// bevel1 = if true, bevel the outside of the nut bottom.
// bevel2 = if true, bevel the outside of the nut top.
// bevang = set the angle for the outside nut bevel. Default: 15
// ibevel = if true, bevel the inside (the hole). Default: true
// ibevel1 = if true bevel the inside, bottom end.
// ibevel2 = if true bevel the inside, top end.
// 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`
@ -879,9 +920,10 @@ module square_threaded_rod(
function square_threaded_nut(
nutwidth, id, h,
pitch,
shape=shape,
left_handed=false,
bevel,bevel1,bevel2,
bevel,bevel1,bevel2,bevang=15,
ibevel,ibevel1,ibevel2,
height,thickness,
starts=1,
anchor, spin, orient
) = no_function("square_threaded_nut");
@ -889,16 +931,20 @@ module square_threaded_nut(
nutwidth, id, h,
pitch,
left_handed=false,
bevel,bevel1,bevel2,
bevel,bevel1,bevel2,bevang=15,
ibevel,ibevel1,ibevel2,
height,thickness,
starts=1,
anchor, spin, orient
) {
assert(is_num(pitch) && pitch>0)
assert(is_num(pitch) && pitch>=0)
trapezoidal_threaded_nut(
nutwidth=nutwidth, id=id, h=h, pitch=pitch,
thread_angle=0,
left_handed=left_handed,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
bevel=bevel,bevel1=bevel1,bevel2=bevel2, bevang=bevang,
ibevel=ibevel, ibevel1=ibevel1, ibevel2=ibevel2,
height=height,thickness=thickness,
starts=starts,
anchor=anchor,
spin=spin,
@ -911,12 +957,12 @@ module square_threaded_nut(
// Module: ball_screw_rod()
// Usage:
// ball_screw_rod(d, l, pitch, [ball_diam], [ball_arc], [internal=], ...) [ATTACHMENTS];
// ball_screw_rod(d, l|length, pitch, [ball_diam], [ball_arc], [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs a ball screw rod. This type of rod is used with ball bearings.
// Arguments:
// d = Outer diameter of threaded rod.
// l = length of threaded rod.
// l / length = length of threaded rod.
// pitch = Thread spacing. Also, the diameter of the ball bearings used.
// ball_diam = The diameter of the ball bearings to use with this ball screw.
// ball_arc = The arc portion that should touch the ball bearings. Default: 120 degrees.
@ -947,7 +993,7 @@ function ball_screw_rod(
starts=1,
left_handed=false,
internal=false,
bevel,bevel1,bevel2,
bevel,bevel1,bevel2, length,
anchor, spin, orient
) = no_function("ball_screw_rod");
module ball_screw_rod(
@ -956,7 +1002,7 @@ module ball_screw_rod(
starts=1,
left_handed=false,
internal=false,
bevel,bevel1,bevel2,
bevel,bevel1,bevel2, length,
anchor, spin, orient
) {
n = max(3,ceil(segs(ball_diam/2)*ball_arc/2/360));
@ -973,7 +1019,7 @@ module ball_screw_rod(
starts=starts,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
internal=internal,
higbee=0,
higbee=0, length=length,
anchor=anchor,
spin=spin,
orient=orient
@ -986,7 +1032,7 @@ module ball_screw_rod(
// Module: generic_threaded_rod()
// Usage:
// generic_threaded_rod(d, l, pitch, profile, [internal=], ...) [ATTACHMENTS];
// generic_threaded_rod(d, l|length, pitch, profile, [internal=], ...) [ATTACHMENTS];
// Description:
// Constructs a generic threaded rod using an arbitrary thread profile that you supply. The rod can be tapered (e.g. for pipe threads).
// For specific thread types use other modules that supply the appropriate profile.
@ -1008,7 +1054,7 @@ module ball_screw_rod(
// only works for external threads. It is ignored if internal is true.
// Arguments:
// d = Outer diameter of threaded rod.
// l = Length of threaded rod.
// l / length = Length of threaded rod.
// pitch = Thread spacing.
// profile = A 2D path giving the shape of a thread
// ---
@ -1023,7 +1069,6 @@ module ball_screw_rod(
// higbee = Angle to taper thread ends over. Default: 0 (No higbee thread tapering)
// higbee1 = Angle to taper bottom thread end over.
// higbee2 = Angle to taper top thread end over.
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=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`
@ -1059,9 +1104,9 @@ function generic_threaded_rod(
bevel1, bevel2,
starts=1,
internal=false,
d1, d2,
d1, d2, length,
higbee, higbee1, higbee2,
center, anchor, spin, orient
anchor, spin, orient
) = no_function("generic_threaded_rod");
module generic_threaded_rod(
d, l, pitch, profile,
@ -1070,10 +1115,11 @@ module generic_threaded_rod(
bevel1, bevel2,
starts=1,
internal=false,
d1, d2,
d1, d2, length,
higbee, higbee1, higbee2,
center, anchor, spin, orient
anchor, spin, orient
) {
l = one_defined([l,length],"l,length");
dummy0 =
assert(all_positive(pitch))
assert(all_positive(l))
@ -1162,7 +1208,6 @@ module generic_threaded_rod(
slope = (_r1-_r2)/l;
maxlen = 2*pitch;
anchor = get_anchor(anchor, center, BOT, CENTER);
attachable(anchor,spin,orient, r1=_r1, r2=_r2, l=l) {
union(){
@ -1215,23 +1260,27 @@ module generic_threaded_rod(
// Module: generic_threaded_nut()
// Usage:
// generic_threaded_nut(nutwidth, id, h, pitch, profile, [$slop], ...) [ATTACHMENTS];
// generic_threaded_nut(nutwidth, id, h|height|thickness, pitch, profile, [$slop], ...) [ATTACHMENTS];
// Description:
// Constructs a hexagonal or square nut for an generic threaded rod using a user-supplied thread profile.
// See generic_threaded_rod for details on the profile specification.
// See {{generic_threaded_rod()}} for details on the profile specification.
// Arguments:
// nutwidth = outer dimension of nut from flat to flat.
// id = diameter of threaded rod to screw onto.
// h = height/thickness of nut.
// h / height / thickness = height/thickness of nut.
// pitch = Thread spacing.
// profile = Thread profile.
// ---
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
// left_handed = if true, create left-handed threads. Default = false
// starts = The number of lead starts. Default = 1
// bevel = if true, bevel the thread ends. Default: false
// bevel1 = if true bevel the bottom end.
// bevel2 = if true bevel the top end.
// bevel = if true, bevel the outside of the nut.
// bevel1 = if true, bevel the outside of the nut bottom.
// bevel2 = if true, bevel the outside of the nut top.
// bevang = set the angle for the outside nut bevel. Default: 15
// ibevel = if true, bevel the inside (the hole). Default: true
// ibevel1 = if true bevel the inside, bottom end.
// ibevel2 = if true bevel the inside, top end.
// id1 = inner diameter at the bottom
// id2 = inner diameter at the top
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
@ -1244,11 +1293,12 @@ function generic_threaded_nut(
h,
pitch,
profile,
shape,
shape="hex",
left_handed=false,
starts=1,
bevel,bevel1,bevel2,bevang=15,
id1,id2,
ibevel, ibevel1, ibevel2,
id1,id2, height, thickness,
anchor, spin, orient
) = no_function("generic_threaded_nut");
module generic_threaded_nut(
@ -1261,22 +1311,28 @@ module generic_threaded_nut(
left_handed=false,
starts=1,
bevel,bevel1,bevel2,bevang=15,
id1,id2,
ibevel, ibevel1, ibevel2,
id1,id2, height, thickness,
anchor, spin, orient
) {
assert(in_list(shape,["square","hex"]), "shape must be \"hex\" or \"square\"");
extra = 0.01;
id1 = first_defined([id1,id]);
id2 = first_defined([id2,id]);
assert(is_def(id1) && is_def(id2), "Must specify inner diameter of nut");
h = one_defined([h,height,thickness],"h,height,thickness");
dummyA = assert(is_num(pitch) && pitch>=0, "pitch must be a nonnegative number")
assert(is_num(h) && h>0, "height/thickness must be a positive number")
assert(in_list(shape,["square","hex"]), "shape must be \"hex\" or \"square\"")
assert(all_positive([id1,id2]), "Inner diameter(s) of nut must be positive number(s)");
slope = (id2-id1)/h;
full_id1 = id1-slope*extra/2;
full_id2 = id2+slope*extra/2;
ibevel1 = first_defined([ibevel1,ibevel,true]);
ibevel2 = first_defined([ibevel2,ibevel,true]);
bevel1 = first_defined([bevel1,bevel,false]);
bevel2 = first_defined([bevel2,bevel,false]);
dummy1 = assert(is_num(pitch) && pitch>0);
depth = -pitch*min(column(profile,1));
bevel_d=.975;
bevel_d=0.975;
IBEV=0.05;
vnf = linear_sweep(hexagon(id=nutwidth), height=h, center=true);
attachable(anchor,spin,orient, size=shape=="square" ? [nutwidth,nutwidth,h] : undef, vnf=shape=="hex" ? vnf : undef) {
difference() {
@ -1288,6 +1344,9 @@ module generic_threaded_nut(
if (bevel2) cyl(h=h+.01, d2=nutwidth*bevel_d,d1=nutwidth*bevel_d+h/tan(bevang), $fn=64);
if (bevel1) down(.01) cyl(h=h+.01, d1=nutwidth*bevel_d,d2=nutwidth*bevel_d+h/tan(bevang), $fn=64);
}
if (pitch==0)
cyl(l=h+extra, d1=full_id1+4*get_slop(), d2=full_id2+4*get_slop(), chamfer1=ibevel1?-IBEV*full_id1:undef, chamfer2=ibevel2?-IBEV*full_id2:undef);
else
generic_threaded_rod(
d1=full_id1,d2=full_id2,
l=h+extra,
@ -1296,7 +1355,7 @@ module generic_threaded_nut(
left_handed=left_handed,
starts=starts,
internal=true,
bevel1=bevel1,bevel2=bevel2
bevel1=ibevel1,bevel2=ibevel2
);
}
children();