From 90ac0e2555a0f646ac417170b9de91e49fb553c7 Mon Sep 17 00:00:00 2001 From: Ian Drake Date: Fri, 8 Dec 2023 00:41:00 -0500 Subject: [PATCH] Added nut_sides parameter to allow creation of non-cylinder nut --- docs/README.rst | 6 +++++- threadlib.scad | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/README.rst b/docs/README.rst index 76cf015..4b065e0 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -97,7 +97,11 @@ argument for higbee_arc): :alt: M12x0.5 nut Note that for a nut you also have to specify an outer diameter. The inner -diameter is implicitly given by the thread designator ("M12x0.5" in this case). +diameter is implicitly given by the thread designator ("M12x0.5" in this case). You can set the number of sides for the nut! So you can make hex nuts: + +.. code-block:: OpenScad + + nut("M30", turns=4, Douter=46, nut_sides=6); To make a threaded hole (e.g. in a plate), an intuitive approach would be to create the difference of the plate and a bolt. However, this part would not work diff --git a/threadlib.scad b/threadlib.scad index 52fe35d..d3ed2cf 100644 --- a/threadlib.scad +++ b/threadlib.scad @@ -48,7 +48,8 @@ module bolt(designator, turns, higbee_arc=20, fn=120, table=THREAD_TABLE) { }; }; -module nut(designator, turns, Douter, higbee_arc=20, fn=120, table=THREAD_TABLE) { +module nut(designator, turns, Douter, higbee_arc=20, fn=120, nut_sides=120, table=THREAD_TABLE) { + nut_sides = nut_sides == 120 ? fn : nut_sides; union() { specs = thread_specs(str(designator, "-int"), table=table); P = specs[0]; Dsupport = specs[2]; @@ -57,7 +58,7 @@ module nut(designator, turns, Douter, higbee_arc=20, fn=120, table=THREAD_TABLE) translate([0, 0, -P / 2]) difference() { - cylinder(h=H, d=Douter, $fn=fn); + cylinder(h=H, d=Douter, $fn=nut_sides); translate([0, 0, -0.1]) cylinder(h=H+0.2, d=Dsupport, $fn=fn); };