mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
add square nuts
This commit is contained in:
parent
0278196eeb
commit
42f705b38a
2 changed files with 27 additions and 15 deletions
|
@ -1422,6 +1422,7 @@ module nut(spec, shape, thickness, nutwidth, thread, tolerance, hole_oversize,
|
||||||
mean(struct_val(threadspec, "d_major"))],
|
mean(struct_val(threadspec, "d_major"))],
|
||||||
pitch = struct_val(threadspec, "pitch"),
|
pitch = struct_val(threadspec, "pitch"),
|
||||||
h=thickness,
|
h=thickness,
|
||||||
|
shape=shape,
|
||||||
bevel=bevel,
|
bevel=bevel,
|
||||||
anchor=anchor,spin=spin,orient=orient) children();
|
anchor=anchor,spin=spin,orient=orient) children();
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,13 +130,14 @@ module threaded_rod(
|
||||||
// Usage:
|
// Usage:
|
||||||
// threaded_nut(od, id, h, pitch,...) [ATTACHMENTS];
|
// threaded_nut(od, id, h, pitch,...) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Constructs a hex nut for an ISO (metric) or UTS (English) threaded rod.
|
// Constructs a hex nut or square nut for an ISO (metric) or UTS (English) threaded rod.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// od = diameter of the nut.
|
// od = diameter of the nut.
|
||||||
// id = diameter of threaded rod to screw onto.
|
// id = diameter of threaded rod to screw onto.
|
||||||
// h = height/thickness of nut.
|
// h = height/thickness of nut.
|
||||||
// pitch = Length between threads.
|
// 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
|
// left_handed = if true, create left-handed threads. Default = false
|
||||||
// starts = The number of lead starts. Default: 1
|
// starts = The number of lead starts. Default: 1
|
||||||
// bevel = if true, bevel the thread ends. Default: false
|
// bevel = if true, bevel the thread ends. Default: false
|
||||||
|
@ -151,12 +152,12 @@ module threaded_rod(
|
||||||
// threaded_nut(od=16, id=8, h=8, pitch=1.25, left_handed=true, bevel=true, $slop=0.1, $fa=1, $fs=1);
|
// threaded_nut(od=16, id=8, h=8, pitch=1.25, left_handed=true, bevel=true, $slop=0.1, $fa=1, $fs=1);
|
||||||
function threaded_nut(
|
function threaded_nut(
|
||||||
od, id, h,
|
od, id, h,
|
||||||
pitch, starts=1, left_handed=false, bevel, bevel1, bevel2, id1,id2,
|
pitch, starts=1, shape, left_handed=false, bevel, bevel1, bevel2, id1,id2,
|
||||||
anchor, spin, orient
|
anchor, spin, orient
|
||||||
)=no_function("threaded_nut");
|
)=no_function("threaded_nut");
|
||||||
module threaded_nut(
|
module threaded_nut(
|
||||||
od, id, h,
|
od, id, h,
|
||||||
pitch, starts=1, left_handed=false, bevel, bevel1, bevel2, id1,id2,
|
pitch, starts=1, shape="hex", left_handed=false, bevel, bevel1, bevel2, id1,id2,
|
||||||
anchor, spin, orient
|
anchor, spin, orient
|
||||||
) {
|
) {
|
||||||
dummy1=
|
dummy1=
|
||||||
|
@ -187,7 +188,7 @@ module threaded_nut(
|
||||||
id=basic ? id : id[2], id1=id1, id2=id2,
|
id=basic ? id : id[2], id1=id1, id2=id2,
|
||||||
h=h,
|
h=h,
|
||||||
pitch=pitch,
|
pitch=pitch,
|
||||||
profile=profile,starts=starts,
|
profile=profile,starts=starts,shape=shape,
|
||||||
left_handed=left_handed,
|
left_handed=left_handed,
|
||||||
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
|
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
|
||||||
anchor=anchor, spin=spin,
|
anchor=anchor, spin=spin,
|
||||||
|
@ -324,7 +325,7 @@ module trapezoidal_threaded_rod(
|
||||||
// Usage:
|
// Usage:
|
||||||
// trapezoidal_threaded_nut(od, id, h, pitch, [thread_angle], [thread_depth], ...) [ATTACHMENTS];
|
// trapezoidal_threaded_nut(od, id, h, pitch, [thread_angle], [thread_depth], ...) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Constructs a hex nut for a symmetric trapzoidal threaded rod.
|
// Constructs a hex nut or square nut for a symmetric trapzoidal threaded rod.
|
||||||
// By default produces the nominal dimensions
|
// By default produces the nominal dimensions
|
||||||
// for metric trapezoidal threads: a thread angle of 30 degrees and a depth set to half the pitch.
|
// for metric trapezoidal threads: a thread angle of 30 degrees and a depth set to half the pitch.
|
||||||
// You can also specify your own trapezoid parameters. For ACME threads see acme_threaded_nut().
|
// You can also specify your own trapezoid parameters. For ACME threads see acme_threaded_nut().
|
||||||
|
@ -336,6 +337,7 @@ module trapezoidal_threaded_rod(
|
||||||
// thread_angle = Angle between two thread faces. Default: 30
|
// thread_angle = Angle between two thread faces. Default: 30
|
||||||
// thread_depth = Depth of the threads. Default: pitch/2
|
// thread_depth = Depth of the threads. Default: pitch/2
|
||||||
// ---
|
// ---
|
||||||
|
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
|
||||||
// left_handed = if true, create left-handed threads. Default = false
|
// left_handed = if true, create left-handed threads. Default = false
|
||||||
// starts = The number of lead starts. Default = 1
|
// starts = The number of lead starts. Default = 1
|
||||||
// bevel = if true, bevel the thread ends. Default: false
|
// bevel = if true, bevel the thread ends. Default: false
|
||||||
|
@ -353,7 +355,7 @@ module trapezoidal_threaded_rod(
|
||||||
function trapezoidal_threaded_rod(
|
function trapezoidal_threaded_rod(
|
||||||
d, l, pitch,
|
d, l, pitch,
|
||||||
thread_angle=30,
|
thread_angle=30,
|
||||||
thread_depth=undef,
|
thread_depth=undef, shape,
|
||||||
left_handed=false,
|
left_handed=false,
|
||||||
bevel,bevel1,bevel2,
|
bevel,bevel1,bevel2,
|
||||||
starts=1,
|
starts=1,
|
||||||
|
@ -367,7 +369,7 @@ module trapezoidal_threaded_nut(
|
||||||
h,
|
h,
|
||||||
pitch,
|
pitch,
|
||||||
thread_angle=30,
|
thread_angle=30,
|
||||||
thread_depth,
|
thread_depth, shape="hex",
|
||||||
left_handed=false,
|
left_handed=false,
|
||||||
starts=1,
|
starts=1,
|
||||||
bevel,bevel1,bevel2,
|
bevel,bevel1,bevel2,
|
||||||
|
@ -388,7 +390,7 @@ module trapezoidal_threaded_nut(
|
||||||
[ z2, rr1],
|
[ z2, rr1],
|
||||||
];
|
];
|
||||||
generic_threaded_nut(od=od,id=id,h=h,pitch=pitch,profile=profile,id1=id1,id2=id2,
|
generic_threaded_nut(od=od,id=id,h=h,pitch=pitch,profile=profile,id1=id1,id2=id2,
|
||||||
left_handed=left_handed,bevel=bevel,bevel1=bevel1,bevel2=bevel2,starts=starts,
|
shape=shape,left_handed=left_handed,bevel=bevel,bevel1=bevel1,bevel2=bevel2,starts=starts,
|
||||||
anchor=anchor,spin=spin,orient=orient)
|
anchor=anchor,spin=spin,orient=orient)
|
||||||
children();
|
children();
|
||||||
}
|
}
|
||||||
|
@ -473,6 +475,7 @@ module acme_threaded_rod(
|
||||||
// tpi = threads per inch
|
// tpi = threads per inch
|
||||||
// ---
|
// ---
|
||||||
// pitch = Thread spacing (alternative to tpi)
|
// 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
|
// left_handed = if true, create left-handed threads. Default = false
|
||||||
// starts = Number of lead starts. Default: 1
|
// starts = Number of lead starts. Default: 1
|
||||||
// bevel = if true, bevel the thread ends. Default: false
|
// bevel = if true, bevel the thread ends. Default: false
|
||||||
|
@ -488,14 +491,14 @@ module acme_threaded_rod(
|
||||||
function acme_threaded_nut(
|
function acme_threaded_nut(
|
||||||
od, id, h, tpi, pitch,
|
od, id, h, tpi, pitch,
|
||||||
starts=1,
|
starts=1,
|
||||||
left_handed=false,
|
left_handed=false,shape,
|
||||||
bevel,bevel1,bevel2,
|
bevel,bevel1,bevel2,
|
||||||
anchor, spin, orient
|
anchor, spin, orient
|
||||||
) = no_function("acme_threaded_nut");
|
) = no_function("acme_threaded_nut");
|
||||||
module acme_threaded_nut(
|
module acme_threaded_nut(
|
||||||
od, id, h, tpi, pitch,
|
od, id, h, tpi, pitch,
|
||||||
starts=1,
|
starts=1,
|
||||||
left_handed=false,
|
left_handed=false,shape="hex",
|
||||||
bevel,bevel1,bevel2,
|
bevel,bevel1,bevel2,
|
||||||
anchor, spin, orient
|
anchor, spin, orient
|
||||||
) {
|
) {
|
||||||
|
@ -505,7 +508,7 @@ module acme_threaded_nut(
|
||||||
trapezoidal_threaded_nut(
|
trapezoidal_threaded_nut(
|
||||||
od=od, id=id, h=h, pitch=pitch,
|
od=od, id=id, h=h, pitch=pitch,
|
||||||
thread_depth = pitch/2,
|
thread_depth = pitch/2,
|
||||||
thread_angle=29,
|
thread_angle=29,shape=shape,
|
||||||
left_handed=left_handed,
|
left_handed=left_handed,
|
||||||
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
|
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
|
||||||
starts=starts,
|
starts=starts,
|
||||||
|
@ -731,6 +734,7 @@ module buttress_threaded_rod(
|
||||||
// h = height/thickness of nut.
|
// h = height/thickness of nut.
|
||||||
// pitch = Thread spacing.
|
// pitch = Thread spacing.
|
||||||
// ---
|
// ---
|
||||||
|
// shape = specifies shape of nut, either "hex" or "square". Default: "hex"
|
||||||
// left_handed = if true, create left-handed threads. Default = false
|
// left_handed = if true, create left-handed threads. Default = false
|
||||||
// starts = The number of lead starts. Default: 1
|
// starts = The number of lead starts. Default: 1
|
||||||
// bevel = if true, bevel the thread ends. Default: false
|
// bevel = if true, bevel the thread ends. Default: false
|
||||||
|
@ -744,13 +748,13 @@ module buttress_threaded_rod(
|
||||||
// buttress_threaded_nut(od=16, id=8, h=8, pitch=1.25, left_handed=true, $slop=0.05, $fa=1, $fs=1);
|
// buttress_threaded_nut(od=16, id=8, h=8, pitch=1.25, left_handed=true, $slop=0.05, $fa=1, $fs=1);
|
||||||
function buttress_threaded_nut(
|
function buttress_threaded_nut(
|
||||||
od=16, id=10, h=10,
|
od=16, id=10, h=10,
|
||||||
pitch=2, left_handed=false,
|
pitch=2, shape, left_handed=false,
|
||||||
bevel,bevel1,bevel2,starts,
|
bevel,bevel1,bevel2,starts,
|
||||||
anchor, spin, orient
|
anchor, spin, orient
|
||||||
) = no_function("buttress_threaded_nut");
|
) = no_function("buttress_threaded_nut");
|
||||||
module buttress_threaded_nut(
|
module buttress_threaded_nut(
|
||||||
od=16, id=10, h=10,
|
od=16, id=10, h=10,
|
||||||
pitch=2, left_handed=false,
|
pitch=2, shape="hex", left_handed=false,
|
||||||
bevel,bevel1,bevel2,starts=1,
|
bevel,bevel1,bevel2,starts=1,
|
||||||
anchor, spin, orient
|
anchor, spin, orient
|
||||||
) {
|
) {
|
||||||
|
@ -766,6 +770,7 @@ module buttress_threaded_nut(
|
||||||
od=od, id=id, h=h,
|
od=od, id=id, h=h,
|
||||||
pitch=pitch,
|
pitch=pitch,
|
||||||
profile=profile,
|
profile=profile,
|
||||||
|
shape=shape,
|
||||||
left_handed=left_handed,starts=starts,
|
left_handed=left_handed,starts=starts,
|
||||||
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
|
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
|
||||||
anchor=anchor, spin=spin,
|
anchor=anchor, spin=spin,
|
||||||
|
@ -1210,7 +1215,7 @@ module generic_threaded_rod(
|
||||||
// Usage:
|
// Usage:
|
||||||
// generic_threaded_nut(od, id, h, pitch, profile, [$slop], ...) [ATTACHMENTS];
|
// generic_threaded_nut(od, id, h, pitch, profile, [$slop], ...) [ATTACHMENTS];
|
||||||
// Description:
|
// Description:
|
||||||
// Constructs a hexagonal nut for an generic threaded rod using a user-supplied thread profile.
|
// 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:
|
// Arguments:
|
||||||
// od = diameter of the nut.
|
// od = diameter of the nut.
|
||||||
|
@ -1236,6 +1241,7 @@ function generic_threaded_nut(
|
||||||
h,
|
h,
|
||||||
pitch,
|
pitch,
|
||||||
profile,
|
profile,
|
||||||
|
shape,
|
||||||
left_handed=false,
|
left_handed=false,
|
||||||
starts=1,
|
starts=1,
|
||||||
bevel,bevel1,bevel2,bevang=30,
|
bevel,bevel1,bevel2,bevang=30,
|
||||||
|
@ -1248,12 +1254,14 @@ module generic_threaded_nut(
|
||||||
h,
|
h,
|
||||||
pitch,
|
pitch,
|
||||||
profile,
|
profile,
|
||||||
|
shape="hex",
|
||||||
left_handed=false,
|
left_handed=false,
|
||||||
starts=1,
|
starts=1,
|
||||||
bevel,bevel1,bevel2,
|
bevel,bevel1,bevel2,
|
||||||
id1,id2,
|
id1,id2,
|
||||||
anchor, spin, orient
|
anchor, spin, orient
|
||||||
) {
|
) {
|
||||||
|
assert(in_list(shape,["square","hex"]), "shape must be \"hex\" or \"square\"");
|
||||||
extra = 0.01;
|
extra = 0.01;
|
||||||
id1 = first_defined([id1,id]);
|
id1 = first_defined([id1,id]);
|
||||||
id2 = first_defined([id2,id]);
|
id2 = first_defined([id2,id]);
|
||||||
|
@ -1267,7 +1275,10 @@ module generic_threaded_nut(
|
||||||
depth = -pitch*min(column(profile,1));
|
depth = -pitch*min(column(profile,1));
|
||||||
attachable(anchor,spin,orient, size=[od/cos(30),od,h]) {
|
attachable(anchor,spin,orient, size=[od/cos(30),od,h]) {
|
||||||
difference() {
|
difference() {
|
||||||
cyl(d=od/cos(30), h=h, center=true, $fn=6,chamfer1=bevel1?depth:undef,chamfer2=bevel2?depth:undef);
|
if (shape=="hex")
|
||||||
|
cyl(d=od/cos(30), h=h, center=true, $fn=6,chamfer1=bevel1?depth:undef,chamfer2=bevel2?depth:undef);
|
||||||
|
else
|
||||||
|
cuboid([od,od,h]);
|
||||||
generic_threaded_rod(
|
generic_threaded_rod(
|
||||||
d1=full_id1,d2=full_id2,
|
d1=full_id1,d2=full_id2,
|
||||||
l=h+extra,
|
l=h+extra,
|
||||||
|
|
Loading…
Reference in a new issue