From a15e3e1d43fd6acca437e0396f8db4e3d72fb10c Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Sat, 10 Dec 2022 09:49:04 -0500 Subject: [PATCH] screws fix, arc_copies doc fix, sortidx bugfix --- comparisons.scad | 1 - distributors.scad | 2 +- screws.scad | 5 +++-- tests/test_comparisons.scad | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/comparisons.scad b/comparisons.scad index 15ea570..6dc8379 100644 --- a/comparisons.scad +++ b/comparisons.scad @@ -728,7 +728,6 @@ function sort(list, idx=undef) = // idxs3 = sortidx(lst, idx=[1,3]); // Returns: [3,0,2,1] function sortidx(list, idx=undef) = assert(is_list(list)||is_string(list), "Invalid list." ) - !is_list(list) || len(list)<=1 ? list : is_homogeneous(list,1) ? let( size = list_shape(list[0]), diff --git a/distributors.scad b/distributors.scad index 36adb19..cdbe179 100644 --- a/distributors.scad +++ b/distributors.scad @@ -775,7 +775,7 @@ module zrot_copies(rots=[], cp=[0,0,0], n, sa=0, r, d, subrot=true) // d = diameter of circle. (Default: 2) // dx = diameter of ellipse on X axis. Used instead of d. // dy = diameter of ellipse on Y axis. Used instead of d. -// rot = whether to rotate the copied children. (Default: false) +// rot = whether to rotate the copied children. (Default: true) // sa = starting angle. (Default: 0.0) // ea = ending angle. Will distribute copies CCW from sa to ea. (Default: 360.0) // diff --git a/screws.scad b/screws.scad index adb4d2c..97ebfab 100644 --- a/screws.scad +++ b/screws.scad @@ -925,11 +925,12 @@ module screw_hole(spec, head, thread, oversize, hole_oversize, head_oversize, parse_int(substr(tolerance,1)) : assert(false,str("Unknown tolerance ",tolerance, " for clearance hole")); tol_table = struct_val(screwspec,"system")=="UTS" ? UTS_clearance[tol_ind] : ISO_clearance[tol_ind]; + tol_gap = lookup(_nominal_diam(screwspec), tol_table); // If we got here, hole_oversize is undefined and oversize is undefined hole_oversize = downcase(tolerance)=="tap" ? -pitch : downcase(tolerance)=="self tap" ? -pitch*lookup(pitch,[[1,0.72],[1.5,.6]]) - : lookup(_nominal_diam(screwspec), tol_table); - head_oversize = first_defined([head_oversize,hole_oversize]); + : tol_gap; + head_oversize = default(head_oversize, tol_gap); default_tag("remove") screw(spec,head=head,thread=0,shaft_undersize=-hole_oversize, head_undersize=-head_oversize, length=length,l=l,thread_len=thread_len, _counterbore=counterbore, diff --git a/tests/test_comparisons.scad b/tests/test_comparisons.scad index 56b2f96..31ec78f 100644 --- a/tests/test_comparisons.scad +++ b/tests/test_comparisons.scad @@ -16,6 +16,10 @@ test_sort(); module test_sortidx() { + assert(sortidx([3]) == [0]); + assert(sortidx([]) == []); + assert(sortidx([[5,6,7]])==[0]); + assert(sortidx(["abc"]) == [0]); lst1 = ["da","bax","eaw","cav"]; assert(sortidx(lst1) == [1,3,0,2]); lst5 = [3,5,1,7];