From 93b260b7b9a016e2afe1ab7df22f5c0c8c906708 Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Fri, 15 Jan 2021 18:12:37 +0000 Subject: [PATCH] Added screw_length() to calculuate screw lengths includin washers, inserts and nuts. --- docs/usage.md | 2 +- printed/box.scad | 6 +++--- printed/camera_housing.scad | 5 ++--- printed/corner_block.scad | 10 ++++------ printed/door_hinge.scad | 20 ++++++++++---------- printed/door_latch.scad | 2 +- printed/fixing_block.scad | 4 +--- printed/flat_hinge.scad | 4 +--- printed/foot.scad | 7 ++----- printed/handle.scad | 2 +- printed/pcb_mount.scad | 3 +-- printed/printed_box.scad | 6 ++---- printed/psu_shroud.scad | 3 +-- printed/ribbon_clamp.scad | 3 +-- printed/socket_box.scad | 3 +-- printed/ssr_shroud.scad | 3 +-- printed/strap_handle.scad | 6 ++---- readme.md | 5 +++-- tests/BOM.scad | 3 +-- tests/blowers.scad | 5 +---- vitamins/fan.scad | 6 ++---- vitamins/iec.scad | 7 ++----- vitamins/module.scad | 6 ++---- vitamins/pcb.scad | 6 ++---- vitamins/ring_terminal.scad | 2 +- vitamins/screw.scad | 12 ++++++++++-- vitamins/ssr.scad | 6 ++---- vitamins/veroboard.scad | 3 +-- 28 files changed, 62 insertions(+), 88 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index e783509..010f688 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -182,7 +182,7 @@ This is achieved by having a pair of modules: - } module handle_fastened_assembly(thickness) { //! Assembly with fasteners in place - screw_length = screw_longer_than(thickness + insert_length(insert) + 2 * washer_thickness(screw_washer(screw))); + screw_length = screw_length(screw, thickness, 2, true, longer = true); handle_assembly(); diff --git a/printed/box.scad b/printed/box.scad index 6cfa7ff..43bd09d 100644 --- a/printed/box.scad +++ b/printed/box.scad @@ -75,9 +75,9 @@ function box_corner_overlap(type) = box_wall(type); function box_corner_rad(type) = box_sheet_slot(type) - sheet_slot_clearance / 2 + box_corner_gap(type) + box_corner_overlap(type); function box_sheet_r(type) = box_corner_rad(type) - box_sheet_slot(type) - box_corner_overlap(type); -function box_screw_length(type, top) = screw_longer_than(2 * washer_thickness(box_washer(type)) - + sheet_thickness(top ? box_top_sheet(type) : box_base_sheet(type)) - + box_corner_gap(type) + box_profile_overlap(type) + box_insert_l(type) - 1); +function box_screw_length(type, top) = + let(s = top ? box_top_sheet(type) : box_base_sheet(type)) + screw_length(box_screw(type), sheet_thickness(s) + box_corner_gap(type) + box_profile_overlap(type) - 1, washers = 2, insert = true, longer = true); function box_wall_clearance(type) = box_sheet_slot(type) / 2 - sheet_thickness(box_sheets(type)) / 2; function box_margin(type) = box_profile_overlap(type) + box_corner_gap(type); //! How much the bezel intrudes on the specified height diff --git a/printed/camera_housing.scad b/printed/camera_housing.scad index 366b8c2..486f8fe 100644 --- a/printed/camera_housing.scad +++ b/printed/camera_housing.scad @@ -68,7 +68,7 @@ function cam_screw_length(cam) = let( front = cam_front_size(cam), screw = pcb_screw(camera_pcb(cam)), nut = screw_nut(screw) - ) screw_longer_than(front.z + washer_thickness(screw_washer(screw)) - nut_trap_depth(nut) + nut_thickness(nut, true)); + ) screw_length(screw, front.z - nut_trap_depth(nut), 1, nyloc = true, longer = true); function hinge_z(cam) = cam_screw_length(cam) - hinge_r; @@ -344,9 +344,8 @@ module camera_fastened_assembly(cam, thickness, angle = 0) { camera_bracket_position(cam) camera_bracket_screw_positions(cam) { nut = screw_nut(bracket_screw); - washer = screw_washer(bracket_screw); t = bracket_thickness(cam); - screw_length = screw_longer_than(thickness + t + nut_thickness(nut, true) + 2 * washer_thickness(washer)); + screw_length = screw_length(bracket_screw, thickness + t, 2, nyloc = true); vflip() translate_z(thickness) screw_and_washer(bracket_screw, screw_length); diff --git a/printed/corner_block.scad b/printed/corner_block.scad index 9c8f777..aed34fa 100644 --- a/printed/corner_block.scad +++ b/printed/corner_block.scad @@ -133,12 +133,10 @@ assembly(str("corner_block_M", 20 * screw_radius(screw))) { module fastened_corner_block_assembly(thickness, screw = def_screw, thickness_below = undef, thickness_side2 = undef, name = false, show_block = true, star_washers = true) { //! Printed block with all fasteners thickness2 = !is_undef(thickness_below) ? thickness_below : thickness; thickness3 = !is_undef(thickness_side2) ? thickness_side2 : thickness; - washer = screw_washer(screw); - insert = screw_insert(screw); - function screw_length(t) = screw_shorter_than((star_washers ? 2 : 1) * washer_thickness(washer) + t + insert_length(insert) + overshoot); - screw_length = screw_length(thickness); - screw_length2 = screw_length(thickness2); - screw_length3 = screw_length(thickness3); + function screw_len(t) = screw_length(screw, t + overshoot, star_washers ? 2 : 1, true); + screw_length = screw_len(thickness); + screw_length2 = screw_len(thickness2); + screw_length3 = screw_len(thickness3); if(show_block) corner_block_assembly(screw, name) children(); diff --git a/printed/door_hinge.scad b/printed/door_hinge.scad index 87b5ed8..a9a665f 100644 --- a/printed/door_hinge.scad +++ b/printed/door_hinge.scad @@ -136,8 +136,7 @@ module door_hinge_assembly(top, door_thickness = 6) { //! The moving assembly th dir = top ? -1 : 1; pin_x = door_hinge_pin_x(); pin_y = door_hinge_pin_y(); - washer = screw_washer(screw); - screw_length = screw_shorter_than(thickness + door_thickness + washer_thickness(washer)); + screw_length = screw_length(screw, thickness + door_thickness, 1); translate([0, pin_y - (thickness + door_thickness / 2), dir * width / 2]) { rotate([90, 0, 180]) @@ -148,20 +147,20 @@ module door_hinge_assembly(top, door_thickness = 6) { //! The moving assembly th screw_and_washer(screw, screw_length); } - translate([pin_x, pin_y, top ? 0 : -washer_thickness(screw_washer(pin_screw))]) - washer(screw_washer(pin_screw)); + washer = screw_washer(pin_screw); + wt = washer_thickness(washer); + translate([pin_x, pin_y, top ? 0 : -wt]) + washer(washer); - translate([pin_x, pin_y, top ? washer_thickness(screw_washer(pin_screw)) + stat_width : width]) - screw_and_washer(pin_screw, screw_longer_than(2 * washer_thickness(screw_washer(pin_screw)) + width + stat_width)); + translate([pin_x, pin_y, top ? wt + stat_width : width]) + screw_and_washer(pin_screw, screw_length(pin_screw, width + stat_width, 2, longer = true)); } module door_hinge_static_assembly(top, sheet_thickness = 3) { //! The stationary assembly dir = top ? -1 : 1; pin_x = door_hinge_pin_x(); - stat_washer = screw_washer(stat_screw); - stat_nut = screw_nut(stat_screw); - stat_screw_length = screw_longer_than(thickness + sheet_thickness + 2 * washer_thickness(stat_washer) + nut_thickness(stat_nut, true)); + stat_screw_length = screw_length(stat_screw, thickness + sheet_thickness, 2, nyloc = true); translate([pin_x, 0, -dir * (stat_width / 2 + washer_thickness(screw_washer(pin_screw)))]) rotate([90, 0, 0]) { @@ -169,9 +168,10 @@ module door_hinge_static_assembly(top, sheet_thickness = 3) { //! The stationary door_hinge_stat_hole_positions() { screw_and_washer(stat_screw, stat_screw_length); + translate_z(-thickness - sheet_thickness) vflip() - nut_and_washer(stat_nut, true); + nut_and_washer(screw_nut(stat_screw), true); } } } diff --git a/printed/door_latch.scad b/printed/door_latch.scad index 0172710..d695ebb 100644 --- a/printed/door_latch.scad +++ b/printed/door_latch.scad @@ -61,7 +61,7 @@ module door_latch_assembly(sheet_thickness = 3) { //! The assembly for a specifi washer = screw_washer(screw); nut = screw_nut(screw); - screw_length = screw_longer_than(height - nut_trap_depth + sheet_thickness + 2 * washer_thickness(washer) + nut_thickness(nut, true)); + screw_length = screw_length(screw, height - nut_trap_depth + sheet_thickness, 2, nyloc = true); translate([0, -height - washer_thickness(washer)]) rotate([-90, 0, 0]) { diff --git a/printed/fixing_block.scad b/printed/fixing_block.scad index 78c2db4..3611af9 100644 --- a/printed/fixing_block.scad +++ b/printed/fixing_block.scad @@ -122,9 +122,7 @@ assembly(str("fixing_block_M", 20 * screw_radius(screw))) { module fastened_fixing_block_assembly(thickness, screw = def_screw, screw2 = undef, thickness2 = undef, show_block = true, star_washers = true) { //! Assembly with fasteners in place module fb_screw(screw, thickness) { - washer = screw_washer(screw); - insert = screw_insert(screw); - screw_length = screw_longer_than((star_washers ? 2 : 1) * washer_thickness(washer) + thickness + insert_length(insert)); + screw_length = screw_length(screw, thickness, star_washers ? 2 : 1, true, longer = true); if(thickness) translate_z(thickness) diff --git a/printed/flat_hinge.scad b/printed/flat_hinge.scad index 19d8c06..8c4fc17 100644 --- a/printed/flat_hinge.scad +++ b/printed/flat_hinge.scad @@ -155,9 +155,7 @@ module hinge_fastened_assembly(type, thickness1, thickness2, angle, show_hinge = hinge_assembly(type, angle); screw = hinge_screw(type); - washer_t = 2 * washer_thickness(screw_washer(screw)); nut = screw_nut(screw); - nut_t = nut_thickness(nut, true); t = hinge_thickness(type); kr = hinge_knuckle_dia(type) / 2; @@ -165,7 +163,7 @@ module hinge_fastened_assembly(type, thickness1, thickness2, angle, show_hinge = if(thickness) hinge_screw_positions(type) { translate_z(t) - screw_and_washer(screw, screw_longer_than(t + thickness + washer_t + nut_t)); + screw_and_washer(screw, screw_length(screw, t + thickness, 2, nyloc = true)); translate_z(-thickness) vflip() diff --git a/printed/foot.scad b/printed/foot.scad index fe8da82..d55a3e3 100644 --- a/printed/foot.scad +++ b/printed/foot.scad @@ -69,10 +69,9 @@ module foot(type = foot) { //! Generate STL module foot_assembly(t = 0, type = foot, flip = false) { //! Assembly with fasteners in place for specified sheet thickness screw = foot_screw(type); - washer = screw_washer(screw); nut = screw_nut(screw); squeeze = 0.5; - screw_length = screw_longer_than(foot_thickness(type) + t + 2 * washer_thickness(washer) + nut_thickness(nut, true) - squeeze); + screw_length = screw_length(screw, foot_thickness(type) + t - squeeze, 2, nyloc = true); vflip() explode(15, true) { stl_colour(pp4_colour) foot(type); @@ -146,9 +145,7 @@ assembly("insert_foot") { module fastened_insert_foot_assembly(t = 3, type = insert_foot) { //! Assembly with fasteners in place for specified sheet thickness screw = foot_screw(type); - washer = screw_washer(screw); - insert = screw_insert(screw); - screw_length = screw_shorter_than(insert_length(insert) + t + 2 * washer_thickness(washer)); + screw_length = screw_length(screw, t, 2, insert = true); explode(-10) insert_foot_assembly(type); diff --git a/printed/handle.scad b/printed/handle.scad index 53bfb38..881fc60 100644 --- a/printed/handle.scad +++ b/printed/handle.scad @@ -91,7 +91,7 @@ assembly("handle") { } module handle_fastened_assembly(thickness) { //! Assembly with fasteners in place - screw_length = screw_longer_than(thickness + insert_length(insert) + 2 * washer_thickness(screw_washer(screw))); + screw_length = screw_length(screw, thickness, 2, true, longer = true); handle_assembly(); diff --git a/printed/pcb_mount.scad b/printed/pcb_mount.scad index d6e3c64..178a2b0 100644 --- a/printed/pcb_mount.scad +++ b/printed/pcb_mount.scad @@ -103,10 +103,9 @@ module pcb_mount_assembly(pcb, thickness, height = 5) { //! A PCB mount assembly stl_colour(pp1_colour) pcb_mount(pcb, washers = false); - washer = screw_washer(screw); nut = screw_nut(screw); t = pcb_thickness(pcb); - screw_length = screw_longer_than(height + t + washer_thickness + thickness + washer_thickness(washer) + nut_thickness(nut, true)); + screw_length = screw_length(screw, height + t + washer_thickness + thickness, 1, nyloc = true); pcb_mount_screw_positions(pcb) { translate_z(height + t) { diff --git a/printed/printed_box.scad b/printed/printed_box.scad index bf196a7..7ee0167 100644 --- a/printed/printed_box.scad +++ b/printed/printed_box.scad @@ -65,10 +65,8 @@ function pbox_insert(type) = screw_insert(pbox_screw(type)); //! The insert for function pbox_washer(type) = screw_washer(pbox_screw(type)); //! The washer for the base screws function pbox_screw_length(type, panel_thickness = 0) = //! Length of the base screw - let(foot = pbox_foot(type)) - screw_shorter_than(pbox_base(type) + washer_thickness(pbox_washer(type)) - + insert_length(pbox_insert(type)) - + (foot ? foot_thickness(foot) : panel_thickness)); + let(foot = pbox_foot(type), screw = pbox_screw(type)) + screw_length(screw, pbox_base(type) + (foot ? foot_thickness(foot) : panel_thickness), 1, true); function pbox_mid_offset(type) = pbox_ridges(type).y + pbox_wall(type) / 2; // Offset to wall midpoint diff --git a/printed/psu_shroud.scad b/printed/psu_shroud.scad index 23732f7..8343fc9 100644 --- a/printed/psu_shroud.scad +++ b/printed/psu_shroud.scad @@ -156,8 +156,7 @@ assembly(str("PSU_shroud_", name)) { module psu_shroud_fastened_assembly(type, cable_d, thickness, name, cables = 1) //! Assembly with screws in place { - washer = screw_washer(screw); - screw_length = screw_shorter_than(2 * washer_thickness(washer) + thickness + insert_length(insert) + counter_bore); + screw_length = screw_length(screw,thickness + counter_bore, 2, true); psu_shroud_assembly(type, cable_d, name, cables); diff --git a/printed/ribbon_clamp.scad b/printed/ribbon_clamp.scad index 19ae83c..6bbd41b 100644 --- a/printed/ribbon_clamp.scad +++ b/printed/ribbon_clamp.scad @@ -101,8 +101,7 @@ module ribbon_clamp_fastened_assembly(ways, thickness, screw = screw) { //! Clam vitamin(str(": Tape self amalgamating silicone ",tape_l," x 25mm")); - washer = screw_washer(screw); - screw_length = screw_shorter_than(2 * washer_thickness(washer) + thickness + ribbon_clamp_screw_depth(screw)); + screw_length = screw_length(screw, thickness + ribbon_clamp_screw_depth(screw), 2); ribbon_clamp_assembly(ways, screw); diff --git a/printed/socket_box.scad b/printed/socket_box.scad index 72e785c..e5f0216 100644 --- a/printed/socket_box.scad +++ b/printed/socket_box.scad @@ -105,8 +105,7 @@ module socket_box_MKLOGIC_assembly() socket_box_assembly(MKLOGIC); module socket_box_fastened_assembly(type, thickness) { //! The socket and backbox on each side of the specified panel thickness screw = mains_socket_screw(type); - insert = screw_insert(screw); - screw_length = screw_longer_than(mains_socket_height(type) + thickness + insert_length(insert)); + screw_length = screw_length(screw, mains_socket_height(type) + thickness, 0, true, longer = true); explode(-50) translate_z(-height - thickness) diff --git a/printed/ssr_shroud.scad b/printed/ssr_shroud.scad index ac9132f..5fbb335 100644 --- a/printed/ssr_shroud.scad +++ b/printed/ssr_shroud.scad @@ -119,8 +119,7 @@ assembly(str("SSR_shroud_", name)) { module ssr_shroud_fastened_assembly(type, cable_d, thickness, name) //! Assembly with screws in place { - washer = screw_washer(screw); - screw_length = screw_shorter_than(2 * washer_thickness(washer) + thickness + insert_length(insert) + counter_bore); + screw_length = screw_length(screw, thickness + counter_bore, 2, true); ssr_shroud_assembly(type, cable_d, name); diff --git a/printed/strap_handle.scad b/printed/strap_handle.scad index 639cab3..e53e3f7 100644 --- a/printed/strap_handle.scad +++ b/printed/strap_handle.scad @@ -172,11 +172,9 @@ assembly("strap_end") { module strap_assembly(length, type = strap) { //! Assembly with screws in place screw = strap_screw(type); - washer = screw_washer(screw); - penny = penny_washer(washer); - insert = strap_insert(type); + penny = penny_washer(screw_washer(screw)); - screw_length = screw_shorter_than(washer_thickness(washer) + washer_thickness(penny) + insert_length(insert) + panel_clearance + counterbore); + screw_length = screw_length(screw, washer_thickness(penny) + panel_clearance + counterbore, 1, true); stl_colour(pp4_colour) strap(length, type); diff --git a/readme.md b/readme.md index a65fa72..96b460b 100644 --- a/readme.md +++ b/readme.md @@ -2902,10 +2902,11 @@ For an explanation of `screw_polysink()` see module blowers() layout([for(b = blowers) blower_width(b)], 10, true) let(b = blowers[$i]){ screw = blower_screw(b); - washer = screw_washer(screw); h = blower_lug(b); blower(b); blower_hole_positions(b) translate_z(h) - screw_and_washer(screw, screw_longer_than(h + washer_thickness(washer) + 5)); - - + screw_and_washer(screw, screw_length(screw, h + 5, 1, longer = true)); } if($preview) diff --git a/vitamins/fan.scad b/vitamins/fan.scad index a8fa237..57f970e 100644 --- a/vitamins/fan.scad +++ b/vitamins/fan.scad @@ -151,10 +151,8 @@ function fan_screw_depth(type, full_depth = false) = fan_boss_d(type) || full_de function fan_screw_length(type, thickness, full_depth = false) = let(depth = fan_screw_depth(type, full_depth), - washers = depth == fan_depth(type) ? 2 : 1, - washer = screw_washer(fan_screw(type)), - nut = screw_nut(fan_screw(type))) - screw_longer_than(thickness + depth + washer_thickness(washer) * washers + nut_thickness(nut, true)); //! Screw length required + washers = depth == fan_depth(type) ? 2 : 1) + screw_length(fan_screw(type), thickness + depth, washers, nyloc = true); //! Screw length required module fan_assembly(type, thickness, include_fan = true, screw = false, full_depth = false) { //! Fan with its fasteners translate_z(-fan_depth(type) / 2) { diff --git a/vitamins/iec.scad b/vitamins/iec.scad index ddebe90..7dd9698 100644 --- a/vitamins/iec.scad +++ b/vitamins/iec.scad @@ -247,10 +247,7 @@ module iec_inserts(type) { //! Place the inserts module iec_assembly(type, thickness) { //! Assembly with fasteners given panel thickness screw = iec_screw(type); - washer = screw_washer(screw); - nut = screw_nut(screw); - insert = screw_insert(screw); - screw_length = thickness ? screw_longer_than(iec_flange_t(type) + thickness + washer_thickness(washer) + nut_thickness(nut, true)) + screw_length = thickness ? screw_length(screw, iec_flange_t(type) + thickness, 1, nyloc = true) : insert_screw_length; iec(type); @@ -262,6 +259,6 @@ module iec_assembly(type, thickness) { //! Assembly with fasteners given panel if(thickness) translate_z(-thickness) vflip() - nut_and_washer(nut, true); + nut_and_washer(screw_nut(screw), true); } } diff --git a/vitamins/module.scad b/vitamins/module.scad index 511ff50..7afcb1b 100644 --- a/vitamins/module.scad +++ b/vitamins/module.scad @@ -129,15 +129,13 @@ module mod_screw_positions(type) //! Position children at the screw positions module module_assembly(type, thickness) { //! Module with its fasteners in place screw = mod_screw(type); - washer = screw_washer(screw); - nut = screw_nut(screw); - screw_length = screw_longer_than(thickness + mod_screw_z(type) + 2 * washer_thickness(washer) + nut_thickness(nut, true)); + screw_length = screw_length(screw, thickness + mod_screw_z(type), 2, nyloc = true); mod(type); mod_screw_positions(type) { translate_z(mod_screw_z(type)) - nut_and_washer(nut, true); + nut_and_washer(screw_nut(screw), true); translate_z(-thickness) vflip() diff --git a/vitamins/pcb.scad b/vitamins/pcb.scad index 8b0b150..21d80b4 100644 --- a/vitamins/pcb.scad +++ b/vitamins/pcb.scad @@ -1121,9 +1121,7 @@ module pcb_assembly(type, height, thickness) { //! Draw PCB assembly with spaces screw = pcb_screw(type); if(!is_undef(screw)) { - washer = screw_washer(screw); - nut = screw_nut(screw); - screw_length = screw_longer_than(height + thickness + pcb_thickness(type) + washer_thickness(washer) + nut_thickness(nut, true)); + screw_length = screw_length(screw, height + thickness + pcb_thickness(type), 1, nyloc = true); taper = screw_smaller_than(pcb_hole_d(type)) > 2 * screw_radius(screw); // Arduino? pcb_screw_positions(type) { @@ -1138,7 +1136,7 @@ module pcb_assembly(type, height, thickness) { //! Draw PCB assembly with spaces translate_z(-thickness) vflip() - nut_and_washer(nut, true); + nut_and_washer(screw_nut(screw), true); } } } diff --git a/vitamins/ring_terminal.scad b/vitamins/ring_terminal.scad index f952595..9c71408 100644 --- a/vitamins/ring_terminal.scad +++ b/vitamins/ring_terminal.scad @@ -128,7 +128,7 @@ module ring_terminal_assembly(type, thickness, top = false) { //! Earthing assem screw = ringterm_screw(type); washer = screw_washer(screw); nut = screw_nut(screw); - screw_length = screw_longer_than(thickness + 2 * washer_thickness(washer) + nut_thickness(nut, true) + ringterm_thickness(type)); + screw_length = screw_length(screw, thickness + ringterm_thickness(type), 2, nyloc = true); explode(10, true) star_washer(washer) if(top) diff --git a/vitamins/screw.scad b/vitamins/screw.scad index 98d9686..8cb9dba 100644 --- a/vitamins/screw.scad +++ b/vitamins/screw.scad @@ -48,7 +48,7 @@ function screw_head_depth(type, d = 0) = //! How far a counter sink ? 0 : let(r = screw_radius(type)) screw_head_radius(type) - max(r, d / 2) + r / 5; -function screw_longer_than(x) = x <= 5 ? 5 : //! Returns shortest screw length longer or equal to x +function screw_longer_than(x) = x <= 5 ? 5 : //! Returns the length of the shortest screw length longer or equal to x x <= 6 ? 6 : x <= 8 ? 8 : x <= 10 ? 10 : @@ -56,7 +56,7 @@ function screw_longer_than(x) = x <= 5 ? 5 : //! Returns shortest screw length x <= 16 ? 16 : ceil(x / 5) * 5; -function screw_shorter_than(x) = x >= 20 ? floor(x / 5) * 5 : //! Returns longest screw length shorter than or equal to x +function screw_shorter_than(x) = x >= 20 ? floor(x / 5) * 5 : //! Returns the length of the longest screw shorter than or equal to x x >= 16 ? 16 : x >= 12 ? 12 : x >= 10 ? 10 : @@ -64,6 +64,14 @@ function screw_shorter_than(x) = x >= 20 ? floor(x / 5) * 5 : //! Returns longes x >= 6 ? 6 : 5; +function screw_length(screw, thickness, washers, insert = false, nyloc = false, nut = false, longer = false) = //! Returns the length of the longest or shortest screw that will got through `thickness` and `washers` and possibly an `insert`, `nut` or `nyloc` + let(washer = washers ? washers * washer_thickness(screw_washer(screw)) : 0, + insert = insert ? insert_length(screw_insert(screw)) : 0, + nut = nut || nyloc ? nut_thickness(screw_nut(screw), nyloc) : 0, + total = thickness + washer + insert + nut + ) + longer || nut || nyloc ? screw_longer_than(total) : screw_shorter_than(total); + function screw_smaller_than(d) = d >= 2.5 && d < 3 ? 2.5 : floor(d); // Largest diameter screw less than or equal to specified diameter function screw_insert(screw, i = 0) = let(d = screw_radius(screw) * 2) diff --git a/vitamins/ssr.scad b/vitamins/ssr.scad index 7ab86f4..0d19274 100644 --- a/vitamins/ssr.scad +++ b/vitamins/ssr.scad @@ -71,15 +71,13 @@ use use module ssr_assembly(type, screw, thickness) { //! Assembly with fasteners in place - nut = screw_nut(screw); - washer = screw_washer(screw); - screw_length = screw_longer_than(2 * washer_thickness(washer) + thickness + ssr_base_t(type) + nut_thickness(nut, true)); + screw_length = screw_length(screw, thickness + ssr_base_t(type), 2, nyloc = true); ssr(type); ssr_hole_positions(type) { translate_z(ssr_base_t(type)) - nut_and_washer(nut, true); + nut_and_washer(screw_nut(screw), true); translate_z(-thickness) vflip() diff --git a/vitamins/veroboard.scad b/vitamins/veroboard.scad index 7cbd720..41c7e6f 100644 --- a/vitamins/veroboard.scad +++ b/vitamins/veroboard.scad @@ -146,9 +146,8 @@ module vero_cutouts(type, angle = undef) vero_components(type, true, angle); //! module veroboard_assembly(type, height, thickness, flip = false) //! Draw the assembly with components and fasteners in place assembly(vero_assembly(type)) { screw = vero_screw(type); - washer = screw_washer(screw); nut = screw_nut(screw); - screw_length = screw_longer_than(height + thickness + vero_thickness(type) + 2 * washer_thickness(washer) + nut_thickness(nut, true)); + screw_length = screw_length(screw, height + thickness + vero_thickness(type), 2, nyloc = true); translate_z(height) { veroboard(type);