diff --git a/scad/conf/utils.scad b/scad/conf/utils.scad index c1bdd0d..7163a33 100644 --- a/scad/conf/utils.scad +++ b/scad/conf/utils.scad @@ -54,31 +54,6 @@ module nut_trap_support(h, r, r2 = 0) { } } -function nut_trap_radius(nut) = nut_radius(nut) + layer_height / 4; -function nut_trap_flat_radius(nut) = nut_trap_radius(nut) * cos(30); - -module nut_trap(screw_r, nut_r, depth, horizontal = false, supported = false) { - render(convexity = 5) union() { - if(horizontal) { - if(screw_r) - teardrop_plus(r = screw_r, h = 200, center = true); - cylinder(r = nut_r + layer_height / 4, h = depth * 2, center = true, $fn = 6); - } - else { - difference() { - union() { - if(screw_r) - poly_cylinder(r = screw_r, h = 200, center = true); - cylinder(r = nut_r, h = depth * 2, center = true, $fn = 6); - } - if(supported) - translate([0, 0, depth - eta]) - cylinder(r = nut_r, h = layer_height, center = false); - } - } - } -} - module part_screw_hole(screw, nut, horizontal = false, supported = false) { screw_r = screw_clearance_radius(screw); if(nut) @@ -107,7 +82,7 @@ module right_triangle(width, height, h, center = true) { module rounded_square(w, h, r) { - union() { + hull() { square([w - 2 * r, h], center = true); square([w, h - 2 * r], center = true); for(x = [-w/2 + r, w/2 - r]) diff --git a/scad/vitamins/nuts.scad b/scad/vitamins/nuts.scad index fb29af9..ce2fe5c 100644 --- a/scad/vitamins/nuts.scad +++ b/scad/vitamins/nuts.scad @@ -7,14 +7,14 @@ // // Washers // -M2_nut = [2, 4.9, 1.6, 2.4, M2_washer, M2_nut_trap_depth]; -M2p5_nut = [2.5, 5.8, 2.2, 3.8, M2p5_washer, M2p5_nut_trap_depth]; -M3_nut = [3, 6.4, 2.4, 4, M3_washer, M3_nut_trap_depth]; -M4_nut = [4, 8.1, 3.2, 5, M4_washer, M4_nut_trap_depth]; -M5_nut = [5, 9.2, 4, 6.25, M5_washer, M5_nut_depth]; -M6_nut = [6, 11.5, 5, 8, M6_washer, M6_nut_depth]; -M6_half_nut = [6, 11.5, 3, 8, M6_washer, 3]; -M8_nut = [8, 15, 6.5, 8, M8_washer, M8_nut_depth]; +M2_nut = [2, 4.9, 1.6, 2.4, M2_washer, M2_nut_trap_depth, 5/2]; +M2p5_nut = [2.5, 5.8, 2.2, 3.8, M2p5_washer, M2p5_nut_trap_depth, 5.9 / 2]; +M3_nut = [3, 6.4, 2.4, 4, M3_washer, M3_nut_trap_depth, M3_nut_radius]; +M4_nut = [4, 8.1, 3.2, 5, M4_washer, M4_nut_trap_depth, M4_nut_radius]; +M5_nut = [5, 9.2, 4, 6.25, M5_washer, M5_nut_depth, M5_nut_radius]; +M6_nut = [6, 11.5, 5, 8, M6_washer, M6_nut_depth, M6_nut_radius]; +M6_half_nut = [6, 11.5, 3, 8, M6_washer, 3, M6_nut_radius]; +M8_nut = [8, 15, 6.5, 8, M8_washer, M8_nut_depth, M8_nut_radius]; function nut_radius(type) = type[1] / 2; function nut_flat_radius(type) = nut_radius(type) * cos(30); @@ -100,3 +100,27 @@ module wingnut(type) { cylinder(r = hole_rad, h = thickness + 2); } } +function nut_trap_radius(nut, horizontal = true, snug = true) = (snug ? nut_radius(nut) : nut[6]) + (horizontal ? layer_height / 4 : 0); +function nut_trap_flat_radius(nut, horizontal = true, snug = true) = nut_trap_radius(nut, horizontal, snug) * cos(30); + +module nut_trap(screw_r, nut_r, depth, horizontal = false, supported = false) { + render(convexity = 5) union() { + if(horizontal) { + if(screw_r) + teardrop_plus(r = screw_r, h = 200, center = true); + cylinder(r = nut_r + layer_height / 4, h = depth * 2, center = true, $fn = 6); + } + else { + difference() { + union() { + if(screw_r) + poly_cylinder(r = screw_r, h = 200, center = true); + cylinder(r = nut_r, h = depth * 2, center = true, $fn = 6); + } + if(supported) + translate([0, 0, depth - eta]) + cylinder(r = nut_r, h = layer_height, center = false); + } + } + } +}