diff --git a/libtest.png b/libtest.png index 9a3e942..c779512 100644 Binary files a/libtest.png and b/libtest.png differ diff --git a/libtest.scad b/libtest.scad index 5efe5f5..6a5169d 100644 --- a/libtest.scad +++ b/libtest.scad @@ -226,7 +226,7 @@ translate([950, 1525]) inserts_y = 0; nuts_y = inserts_y + 20; -washers_y = nuts_y + 120; +washers_y = nuts_y + 140; screws_y = washers_y + 120; circlips_y = screws_y + 180; springs_y = circlips_y + 20; diff --git a/readme.md b/readme.md index 61c47d7..35d4695 100644 --- a/readme.md +++ b/readme.md @@ -2348,6 +2348,7 @@ If a nut is given a child then it gets placed on its top surface. ### Properties | Function | Description | |:--- |:--- | +| `nut_dome(type)` | Dome height and max thread depth if a domed acorn nut | | `nut_pitch(type)` | Pitch if not standard metric course thread | | `nut_radius(type)` | Radius across the corners | | `nut_size(type)` | Diameter of the corresponding screw | @@ -2360,8 +2361,10 @@ If a nut is given a child then it gets placed on its top surface. ### Functions | Function | Description | |:--- |:--- | +| `nut_dome_height(type)` | Height of the domed version | | `nut_flat_radius(type)` | Radius across the flats | | `nut_thickness(type, nyloc = false)` | Thickness of plain or nyloc version | +| `nut_thread_depth(type)` | Max thread depth in domed version | | `nut_trap_flat_radius(nut, horizontal = false)` | Radius across the flats of a nut trap | | `nut_trap_radius(nut, horizontal = false)` | Radius across the corners of a nut trap | | `t_nut_tab(type)` | Sliding t-nut T dimensions | @@ -2369,7 +2372,7 @@ If a nut is given a child then it gets placed on its top surface. ### Modules | Module | Description | |:--- |:--- | -| `nut(type, nyloc = false, brass = false, nylon = false)` | Draw specified nut | +| `nut(type, nyloc = false, brass = false, nylon = false, dome = false)` | Draw specified nut | | `nut_and_washer(type, nyloc)` | Draw nut with corresponding washer | | `nut_square(type, brass = false, nylon = false)` | Draw specified square nut | | `nut_trap(screw, nut, depth = 0, horizontal = false, supported = false, h = 200)` | Make a nut trap | @@ -2390,24 +2393,29 @@ If a nut is given a child then it gets placed on its top surface. | 1 | `sliding_t_nut(M3_sliding_t_nut)` | Nut M3 sliding T | | 1 | `nut(M3_nut)` | Nut M3 x 2.4mm | | 1 | `nut(M3_nut, brass = true)` | Nut M3 x 2.4mm brass | +| 1 | `nut(M3_nut, dome = true)` | Nut M3 x 2.4mm domed | | 1 | `nut(M3_nut, nyloc = true)` | Nut M3 x 2.4mm nyloc | | 1 | `nut(M3nS_thin_nut)` | Nut M3nS 5.5 x 1.8mm | | 1 | `sliding_t_nut(M4_hammer_nut)` | Nut M4 hammer | | 1 | `sliding_t_nut(M4_sliding_t_nut)` | Nut M4 sliding T | | 1 | `nut(M4_nut)` | Nut M4 x 3.2mm | +| 1 | `nut(M4_nut, dome = true)` | Nut M4 x 3.2mm domed | | 1 | `nut(M4_nut, nyloc = true)` | Nut M4 x 3.2mm nyloc | | 1 | `nut(M4nS_thin_nut)` | Nut M4nS 7 x 2.2mm | | 1 | `sliding_t_nut(M5_sliding_t_nut)` | Nut M5 sliding T | | 1 | `nut(M5_nut)` | Nut M5 x 4mm | +| 1 | `nut(M5_nut, dome = true)` | Nut M5 x 4mm domed | | 1 | `nut(M5_nut, nyloc = true)` | Nut M5 x 4mm nyloc | | 1 | `nut(M5nS_thin_nut)` | Nut M5nS 8 x 2.7mm | | 1 | `sliding_t_nut(M6_sliding_t_nut)` | Nut M6 hammer | | 1 | `nut(M6_half_nut)` | Nut M6 x 3mm | | 1 | `nut(M6_nut)` | Nut M6 x 5mm | +| 1 | `nut(M6_nut, dome = true)` | Nut M6 x 5mm domed | | 1 | `nut(M6_nut, nyloc = true)` | Nut M6 x 5mm nyloc | | 1 | `nut(M6nS_thin_nut)` | Nut M6nS 10 x 3.2mm | | 1 | `sliding_t_nut(M8_sliding_ball_t_nut)` | Nut M8 sliding T with spring loaded ball | | 1 | `nut(M8_nut)` | Nut M8 x 6.5mm | +| 1 | `nut(M8_nut, dome = true)` | Nut M8 x 6.5mm domed | | 1 | `nut(M8_nut, nyloc = true)` | Nut M8 x 6.5mm nyloc | | 1 | `nut(M8nS_thin_nut)` | Nut M8nS 13 x 4mm | | 1 | `washer(M6_washer)` | Washer M6 x 12.5mm x 1.5mm | diff --git a/tests/fuseholder.scad b/tests/fuseholder.scad index aab8cf5..c9e1d66 100644 --- a/tests/fuseholder.scad +++ b/tests/fuseholder.scad @@ -20,8 +20,10 @@ include <../utils/core/core.scad> use <../vitamins/fuseholder.scad> +thickness = 6; + module fuseholders() - fuseholder(6); + fuseholder(thickness); if($preview) let($show_threads = 1) diff --git a/tests/nuts.scad b/tests/nuts.scad index 4a3e499..9659629 100644 --- a/tests/nuts.scad +++ b/tests/nuts.scad @@ -25,7 +25,11 @@ module nuts() { translate([0, nyloc ? 20 : 0]) nut(n, nyloc); - translate([0, 40]) { + translate([0, 40]) + if(nut_dome(n)) + nut(n, dome = true); + + translate([0, 60]) { if(n == M3_nut) nut(n, brass = true); @@ -43,7 +47,7 @@ module nuts() { #nut_trap(M8_cap_screw, n, h = 30); } - translate([0, 60]) { + translate([0, 80]) { if(n == M3_nut) sliding_t_nut(M3_sliding_t_nut); @@ -61,7 +65,7 @@ module nuts() { sliding_t_nut(M8_sliding_ball_t_nut); } - translate([0, 80]) { + translate([0, 100]) { if(n == M3_nut) sliding_t_nut(M3_hammer_nut); @@ -69,7 +73,7 @@ module nuts() { sliding_t_nut(M4_hammer_nut); } - translate([0, 100]) { + translate([0, 120]) { if(n == M3_nut) nut_square(M3nS_thin_nut); if(n == M4_nut) diff --git a/tests/png/antennas.png b/tests/png/antennas.png index a308546..3a6a6a2 100644 Binary files a/tests/png/antennas.png and b/tests/png/antennas.png differ diff --git a/tests/png/axials.png b/tests/png/axials.png index 4cd691b..dcfbbfb 100644 Binary files a/tests/png/axials.png and b/tests/png/axials.png differ diff --git a/tests/png/bearing_blocks.png b/tests/png/bearing_blocks.png index 6794b42..84ae37b 100644 Binary files a/tests/png/bearing_blocks.png and b/tests/png/bearing_blocks.png differ diff --git a/tests/png/cable_clip.png b/tests/png/cable_clip.png index 822eb02..559cd3d 100644 Binary files a/tests/png/cable_clip.png and b/tests/png/cable_clip.png differ diff --git a/tests/png/camera_housing.png b/tests/png/camera_housing.png index 1ff0a5c..b6ef415 100644 Binary files a/tests/png/camera_housing.png and b/tests/png/camera_housing.png differ diff --git a/tests/png/door_hinge.png b/tests/png/door_hinge.png index c2be601..41e6845 100644 Binary files a/tests/png/door_hinge.png and b/tests/png/door_hinge.png differ diff --git a/tests/png/door_latch.png b/tests/png/door_latch.png index f566c86..3b6a297 100644 Binary files a/tests/png/door_latch.png and b/tests/png/door_latch.png differ diff --git a/tests/png/fans.png b/tests/png/fans.png index b1a7d17..ad1ceea 100644 Binary files a/tests/png/fans.png and b/tests/png/fans.png differ diff --git a/tests/png/flat_hinge.png b/tests/png/flat_hinge.png index 6a6e5b7..bd9a01e 100644 Binary files a/tests/png/flat_hinge.png and b/tests/png/flat_hinge.png differ diff --git a/tests/png/foot.png b/tests/png/foot.png index a762742..8146aea 100644 Binary files a/tests/png/foot.png and b/tests/png/foot.png differ diff --git a/tests/png/fuseholder.png b/tests/png/fuseholder.png index b71976d..68fe7e0 100644 Binary files a/tests/png/fuseholder.png and b/tests/png/fuseholder.png differ diff --git a/tests/png/iecs.png b/tests/png/iecs.png index 4619b1a..fb0f9ec 100644 Binary files a/tests/png/iecs.png and b/tests/png/iecs.png differ diff --git a/tests/png/jack.png b/tests/png/jack.png index e655bd5..38027b8 100644 Binary files a/tests/png/jack.png and b/tests/png/jack.png differ diff --git a/tests/png/modules.png b/tests/png/modules.png index 7a01193..e0e47e0 100644 Binary files a/tests/png/modules.png and b/tests/png/modules.png differ diff --git a/tests/png/nuts.png b/tests/png/nuts.png index 6739055..85d6ac6 100644 Binary files a/tests/png/nuts.png and b/tests/png/nuts.png differ diff --git a/tests/png/pcb_mount.png b/tests/png/pcb_mount.png index 5fc34aa..3d32bab 100644 Binary files a/tests/png/pcb_mount.png and b/tests/png/pcb_mount.png differ diff --git a/tests/png/pcbs.png b/tests/png/pcbs.png index 382b121..76563fd 100644 Binary files a/tests/png/pcbs.png and b/tests/png/pcbs.png differ diff --git a/tests/png/pillow_blocks.png b/tests/png/pillow_blocks.png index 8639921..9583d1f 100644 Binary files a/tests/png/pillow_blocks.png and b/tests/png/pillow_blocks.png differ diff --git a/tests/png/pocket_handle.png b/tests/png/pocket_handle.png index bd73e03..ef809de 100644 Binary files a/tests/png/pocket_handle.png and b/tests/png/pocket_handle.png differ diff --git a/tests/png/polyholes.png b/tests/png/polyholes.png index 6404177..e0b6d4c 100644 Binary files a/tests/png/polyholes.png and b/tests/png/polyholes.png differ diff --git a/tests/png/potentiometers.png b/tests/png/potentiometers.png index fe4bbd4..0c29215 100644 Binary files a/tests/png/potentiometers.png and b/tests/png/potentiometers.png differ diff --git a/tests/png/rails.png b/tests/png/rails.png index 6cc789c..46b1bc2 100644 Binary files a/tests/png/rails.png and b/tests/png/rails.png differ diff --git a/tests/png/ring_terminals.png b/tests/png/ring_terminals.png index 4b2e09a..f680c47 100644 Binary files a/tests/png/ring_terminals.png and b/tests/png/ring_terminals.png differ diff --git a/tests/png/round.png b/tests/png/round.png index 57ec684..0bb3977 100644 Binary files a/tests/png/round.png and b/tests/png/round.png differ diff --git a/tests/png/screw_knob.png b/tests/png/screw_knob.png index 3c11601..ec4107f 100644 Binary files a/tests/png/screw_knob.png and b/tests/png/screw_knob.png differ diff --git a/tests/png/screws.png b/tests/png/screws.png index 934fb2e..64afde1 100644 Binary files a/tests/png/screws.png and b/tests/png/screws.png differ diff --git a/tests/png/sk_brackets.png b/tests/png/sk_brackets.png index 3b684df..f9d5ed2 100644 Binary files a/tests/png/sk_brackets.png and b/tests/png/sk_brackets.png differ diff --git a/tests/png/socket_box.png b/tests/png/socket_box.png index 99e017e..a05b089 100644 Binary files a/tests/png/socket_box.png and b/tests/png/socket_box.png differ diff --git a/tests/png/ssrs.png b/tests/png/ssrs.png index 1b644d3..1b14b27 100644 Binary files a/tests/png/ssrs.png and b/tests/png/ssrs.png differ diff --git a/tests/png/toggles.png b/tests/png/toggles.png index 53d4e0f..e6408e1 100644 Binary files a/tests/png/toggles.png and b/tests/png/toggles.png differ diff --git a/tests/png/veroboard.png b/tests/png/veroboard.png index 9bbda4e..c6822db 100644 Binary files a/tests/png/veroboard.png and b/tests/png/veroboard.png differ diff --git a/vitamins/fuseholder.scad b/vitamins/fuseholder.scad index 6ec65c0..95010c8 100644 --- a/vitamins/fuseholder.scad +++ b/vitamins/fuseholder.scad @@ -20,7 +20,7 @@ // //! 20mm panel mount fuse holder. // -include <../utils/core/core.scad> +include <../core.scad> include use <../utils/tube.scad> use <../utils/thread.scad> @@ -69,18 +69,10 @@ module fuseholder(thickness) { //! Fuseholder with nut in place for specified pa vflip() translate_z(thickness) explode(height, explode_children = true) { - color(colour) { + color(colour) tube(or = nut_d / 2, ir = thread_d / 2, h = nut_flange_t, center = false); - linear_extrude(nut_t) - difference() { - circle(d = nut_d, $fn = 6); - - circle(d = thread_d); - } - } - if(show_threads && exploded()) - female_metric_thread(thread_d, thread_p, nut_t, false, colour = colour); + draw_nut(nut_d, thread_d, nut_t, thread_p, colour, show_threads && exploded() || thickness > thread); } // // Body diff --git a/vitamins/jack.scad b/vitamins/jack.scad index d34c8cd..40d0224 100644 --- a/vitamins/jack.scad +++ b/vitamins/jack.scad @@ -149,18 +149,8 @@ module jack_4mm_plastic(colour, thickness, display_colour = false) { //! Draw a } translate_z(-thickness) explode(-length) - vflip() { - color(silver) - linear_extrude(nut_t) - difference() { - circle(d = nut_d, $fn = 6); - - circle(d = thread_d); - } - - if(show_threads) - female_metric_thread(thread_d, thread_p, nut_t, false, colour = silver); - } + vflip() + draw_nut(nut_d, thread_d, nut_t, thread_p, silver, show_threads); } function jack_4mm_shielded_hole_radius() = 12 / 2; //! Panel hole radius for 4mm shielded jack @@ -282,14 +272,7 @@ module post_4mm(colour, thickness, display_colour = false) { //! Draw a 4mm bind module nut() { nut_t = 2.3; - color(silver) - linear_extrude(nut_t) difference() { - circle(d = 6.3 / cos(30), $fn = 6); - - circle(d = thread_d); - } - if(show_threads) - female_metric_thread(thread_d, thread_p, nut_t, false, colour = silver); + draw_nut(6.3 / cos(30), thread_d, nut_t, thread_p, silver, show_threads); translate_z(nut_t) children(); @@ -498,16 +481,6 @@ module power_jack(thickness) { //! Draw a power jack socket with nut positioned // Nut translate_z(-thickness) explode(-length) - vflip() { - color(silver) - linear_extrude(nut_t) - difference() { - circle(d = nut_d, $fn = 6); - - circle(d = thread_d); - } - - if(show_threads) - female_metric_thread(thread_d, thread_p, nut_t, false, colour = silver); - } + vflip() + draw_nut(nut_d, thread_d, nut_t, thread_p, silver, show_threads); } diff --git a/vitamins/nut.scad b/vitamins/nut.scad index 2e554b0..f803a3d 100644 --- a/vitamins/nut.scad +++ b/vitamins/nut.scad @@ -37,6 +37,7 @@ function nut_thickness(type, nyloc = false) = nyloc ? type[4] : type[3]; //! Thi function nut_washer(type) = type[5]; //! Corresponding washer function nut_trap_depth(type) = type[6]; //! Depth of nut trap function nut_pitch(type) = type[7]; //! Pitch if not standard metric course thread +function nut_dome(type) = type[8]; //! Dome height and max thread depth if a domed acorn nut function nut_flat_radius(type) = nut_radius(type) * cos(30); //! Radius across the flats @@ -44,36 +45,84 @@ function nut_square_size(type) = type[1]; //! Diameter of the corresponding function nut_square_width(type) = type[2]; //! Width of the square nut function nut_square_thickness(type) = type[3]; //! Thickness of the square nut -module nut(type, nyloc = false, brass = false, nylon = false) { //! Draw specified nut +function nut_dome_height(type) = let(d = nut_dome(type)) d ? d[0] : nut_thickness(type); //! Height of the domed version +function nut_thread_depth(type) = let(d = nut_dome(type)) d ? d[1] : nut_thickness(type); //! Max thread depth in domed version + +module draw_nut(od, id, t, pitch, colour, show_thread, thread_h = undef ) { + th = is_undef(thread_h) ? t : thread_h; + + color(colour) { + or = od / 2; + fr = or * cos(30); + + render_if(manifold) intersection() { + linear_extrude(t, convexity = 5) + difference() { + circle(or, $fn = 6); + + if(id) + circle(d = id); + } + + if(manifold) + rotate_extrude() + hull() { + h = (or - fr) * tan(30); + + translate([0, -eps]) + square([fr, t + eps]); + + translate([or, h]) + square([eps, t - 2 * h]); + } + } + } + if(show_thread && id) + female_metric_thread(id, pitch, + th, + top = th > t ? 0 : manifold ? 1 : -1, + bot = manifold ? 1 : -1, + center = false, colour = colour); +} + +module nut(type, nyloc = false, brass = false, nylon = false, dome = false) { //! Draw specified nut thread_d = nut_size(type); thread_p = nut_pitch(type) ? nut_pitch(type) : metric_coarse_pitch(thread_d); hole_rad = thread_d / 2; outer_rad = nut_radius(type); thickness = nut_thickness(type); nyloc_thickness = nut_thickness(type, true); - desc = nyloc ? "nyloc" : brass ? "brass" : nylon ? "nylon" : ""; - vitamin(str("nut(", type[0], arg(nyloc, false, "nyloc"), arg(brass, false, "brass"), arg(nylon, false, "nylon"), + desc = nyloc ? "nyloc" : brass ? "brass" : nylon ? "nylon" : dome ? "domed" : ""; + vitamin(str("nut(", type[0], + arg(nyloc, false, "nyloc"), + arg(brass, false, "brass"), + arg(nylon, false, "nylon"), + arg(dome, false, "dome"), "): Nut M", nut_size(type), " x ", thickness, "mm ", desc)); $fs = fs; $fa = fa; colour = brass ? brass_colour : nylon ? grey(30): grey(70); explode(nyloc ? 10 : 0) { + draw_nut(outer_rad * 2, thread_d, thickness, thread_p, colour, show_threads, dome ? nut_thread_depth(type) : thickness); + + fr = nut_flat_radius(type); color(colour) { - linear_extrude(thickness) - difference() { - circle(outer_rad, $fn = 6); - - circle(hole_rad); - } - if(nyloc) - translate_z(-eps) - rounded_cylinder(r = outer_rad * cos(30) , h = nyloc_thickness, r2 = (nyloc_thickness - thickness) / 2, ir = hole_rad); - } + translate_z(eps) + rounded_cylinder(r = outer_rad * cos(30), h = nyloc_thickness - eps, r2 = (nyloc_thickness - thickness) / 2, ir = hole_rad); - if(show_threads) - female_metric_thread(thread_d, thread_p, thickness, center = false, colour = colour); + if(dome) + translate_z(thickness) + rotate_extrude() + difference() { + h = nut_dome_height(type) - thickness; + r = fr - eps; + rounded_corner(r, h, r); + + square([thread_d / 2, nut_thread_depth(type) - thickness]); + } + } if(nyloc) translate_z(thickness) diff --git a/vitamins/nuts.scad b/vitamins/nuts.scad index c767dc6..03e14e9 100644 --- a/vitamins/nuts.scad +++ b/vitamins/nuts.scad @@ -28,25 +28,25 @@ M5_nut_depth = 4; M6_nut_depth = 5; M8_nut_depth = 6.5; -// s d t n w t t -// c i h y a r h -// r a i l s a r -// e m c o h p e +// s d t n w t t d d +// c i h y a r h o o +// r a i l s a r m m +// e m c o h p e e e // w e k c e d -// t n r d -// e e t e p -// r s h p i -// s k t t -// h c -// h +// t n r d h t +// e e t e p e h +// r s h p i i r +// s k t t g e +// h c h a +// h t d M2_nut = ["M2_nut", 2, 4.9, 1.6, 2.4, M2_washer, M2_nut_trap_depth, 0]; M2p5_nut = ["M2p5_nut", 2.5, 5.8, 2.2, 3.8, M2p5_washer, M2p5_nut_trap_depth, 0]; -M3_nut = ["M3_nut", 3, 6.4, 2.4, 4, M3_washer, M3_nut_trap_depth, 0]; -M4_nut = ["M4_nut", 4, 8.1, 3.2, 5, M4_washer, M4_nut_trap_depth, 0]; -M5_nut = ["M5_nut", 5, 9.2, 4, 6.25, M5_washer, M5_nut_depth, 0]; -M6_nut = ["M6_nut", 6, 11.5, 5, 8, M6_washer, M6_nut_depth, 0]; +M3_nut = ["M3_nut", 3, 6.4, 2.4, 4, M3_washer, M3_nut_trap_depth, 0, [6, 5.40]]; +M4_nut = ["M4_nut", 4, 8.1, 3.2, 5, M4_washer, M4_nut_trap_depth, 0, [8, 5.74]]; +M5_nut = ["M5_nut", 5, 9.2, 4, 6.25, M5_washer, M5_nut_depth, 0, [10, 7.79]]; +M6_nut = ["M6_nut", 6, 11.5, 5, 8, M6_washer, M6_nut_depth, 0, [12, 8.29]]; M6_half_nut = ["M6_half_nut", 6, 11.5, 3, 8, M6_washer, 3, 0]; -M8_nut = ["M8_nut", 8, 15, 6.5, 8, M8_washer, M8_nut_depth, 0]; +M8_nut = ["M8_nut", 8, 15, 6.5, 8, M8_washer, M8_nut_depth, 0, [15, 11.35]]; toggle_nut = ["toggle_nut", 6.1, 9.2, 1.5, 1.5, M6_washer, 1.5, inch(1/40)]; M4_wingnut = ["M4_wingnut", 4, 10, 3.75,8, M4_washer, 0, 22, 10, 6, 3]; diff --git a/vitamins/potentiometer.scad b/vitamins/potentiometer.scad index 8554cad..5a3f61e 100644 --- a/vitamins/potentiometer.scad +++ b/vitamins/potentiometer.scad @@ -17,7 +17,7 @@ // If not, see . // //! Potentiometers and rotary encoders -include <../utils/core/core.scad> +include <../core.scad> use <../utils/rounded_cylinder.scad> use <../utils/round.scad> use <../utils/thread.scad> @@ -71,18 +71,8 @@ module pot_nut(type, washer = true) { //! Draw the nut for a potentiometer and p } if(nut) - color(nut[2]) - translate_z(nut_z + exploded() * 10) { - linear_extrude(nut[1]) - difference() { - circle(d = nut.x / cos(30), $fn = 6); - - circle(d = thread_d); - } - - if(show_threads && exploded()) - female_metric_thread(thread_d, pot_thread_p(type), nut[1], center = false, colour = nut[2]); - } + translate_z(nut_z + exploded() * 10) + draw_nut(nut.x / cos(30), thread_d, nut[1], pot_thread_p(type), nut[2], show_threads && exploded()); } } diff --git a/vitamins/screw.scad b/vitamins/screw.scad index 9a5a9fa..befca53 100644 --- a/vitamins/screw.scad +++ b/vitamins/screw.scad @@ -205,8 +205,7 @@ module screw(type, length, hob_point = 0, nylon = false) { //! Draw specified sc cylinder(h=2 * eps, r=socket_rad, $fn = 6); } if(head_type == hs_hex) { - color(colour) - cylinder(r = head_rad, h = head_height, $fn = 6); + draw_nut(head_rad * 2, 0, head_height, 0, colour, false); shaft(); }