From e9ee88dfe94860fbb4b77cfbea544c5a92a97b04 Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Sun, 23 Feb 2020 21:41:47 +0000 Subject: [PATCH] Updates as per code review. --- tests/scs_bearing_blocks.scad | 8 +++-- vitamins/scs_bearing_block.scad | 52 ++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/tests/scs_bearing_blocks.scad b/tests/scs_bearing_blocks.scad index 4433c42..093870e 100644 --- a/tests/scs_bearing_blocks.scad +++ b/tests/scs_bearing_blocks.scad @@ -23,13 +23,15 @@ include <../vitamins/scs_bearing_blocks.scad> module scs_bearing_blocks() layout([for(s = scs_bearing_blocks) 2 * scs_size(s)[0]]) { - scs_bearing_block_assembly(scs_bearing_blocks[$i]); + sheet_thickness = 5; + scs_bearing_block_assembly(scs_bearing_blocks[$i], sheet_thickness); if($i > 0) // skip $i==0, since no SCS6LUU long variant to match SCS6UU translate([0, 60]) - scs_bearing_block_assembly(scs_bearing_blocks_long[$i - 1]); + scs_bearing_block_assembly(scs_bearing_blocks_long[$i - 1], sheet_thickness); } if($preview) - scs_bearing_blocks(); + let($show_threads = true) + scs_bearing_blocks(); diff --git a/vitamins/scs_bearing_block.scad b/vitamins/scs_bearing_block.scad index e225b83..ff65792 100644 --- a/vitamins/scs_bearing_block.scad +++ b/vitamins/scs_bearing_block.scad @@ -23,8 +23,10 @@ include -include -include +use +use +use +use function scs_size(type) = [type[4],type[6],type[5]]; //! Size of scs bracket bounding block function scs_hole_offset(type) = type[2]; //! Offset of bearing hole from base of block @@ -119,29 +121,37 @@ module scs_bearing_block(type) { //! Draw the specified SCS bearing block linear_bearing(scs_bearing(type)); } - -module scs_bearing_block_assembly(type, screw_length, screw_type) { //! Assembly with screws and nuts in place - - scs_bearing_block(type); - +module scs_bearing_block_hole_positions(type) { + screw_separation_x = scs_screw_separation_x(type); + screw_separation_z = scs_screw_separation_z(type); G = scs_block_side_height(type); h = scs_hole_offset(type); - screw_type = screw_type ? screw_type : scs_screw(type); - screw_length = screw_length ? screw_length : screw_longer_than(G + 10); - washer_type = screw_washer(screw_type); - washer_thickness = washer_thickness(washer_type); - - screw_separation_x = scs_screw_separation_x(type); - screw_separation_z = scs_screw_separation_z(type); - for(x = [-screw_separation_x, screw_separation_x], z = [-screw_separation_z, screw_separation_z]) translate([x / 2, G - h, z / 2]) - rotate([-90, 0, 0]) { - screw(screw_type, screw_length); - translate_z(-screw_length + washer_thickness) - nut(screw_nut(screw_type)) - washer(washer_type); - } + rotate([-90, 0, 0]) + children(); +} + +module scs_bearing_block_assembly(type, sheet_thickness, screw_type, nut_type) { //! Assembly with screws and nuts in place + + scs_bearing_block(type); + + screw_type = is_undef(screw_type) ? scs_screw(type) : screw_type; + nut_type = is_undef(nut_type) ? screw_nut(screw_type) : nut_type; + washer_type = nut_washer(nut_type); + washer_thickness = washer_type ? washer_thickness(washer_type) : 0; + + G = scs_block_side_height(type); + nut_offset = G + sheet_thickness + nut_thickness(nut_type) + washer_thickness; + screw_length = screw_longer_than(nut_offset); + + scs_bearing_block_hole_positions(type) { + screw(screw_type, screw_length); + translate_z(-nut_offset) + nut(nut_type) + if (washer_type) + washer(washer_type); + } }