From e32381fce93b1bcb5a0968c0b5b785230476b4e6 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Wed, 7 Jan 2026 19:21:29 -0500 Subject: [PATCH 1/2] threaded rod bugfix and improved error handling --- threading.scad | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/threading.scad b/threading.scad index daab0eeb..1d7350e6 100644 --- a/threading.scad +++ b/threading.scad @@ -1664,7 +1664,7 @@ module ball_screw_rod( // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP` // $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads. -// Example(2DMed): Example Tooth Profile +// Example(2DMed,VPD=1.92,VPT=[0.00,-0.30,2.50]): Example Tooth Profile. Note that the X range of the profile must be in [-1/2,1/2] because the profile will be scaled up by the pitch in order to produce the final thread profile. // pitch = 2; // depth = pitch * cos(30) * 5/8; // profile = [ @@ -1676,7 +1676,7 @@ module ball_screw_rod( // [ 7/16, -depth/pitch*1.07] // ]; // stroke(profile, width=0.02); -// Example: +// Example: Here is the screw produced by the profile from Example 1. // pitch = 2; // depth = pitch * cos(30) * 5/8; // profile = [ @@ -1731,6 +1731,7 @@ module generic_threaded_rod( let(ind = search([lead_in_shape], _lead_in_table,0)[0]) assert(ind!=[],str("Unknown lead_in_shape, \"",lead_in_shape,"\"")) _lead_in_table[ind[0]][1]; + profbound = pointlist_bounds(profile); dummy0 = assert(all_positive([pitch]),"Thread pitch must be a positive value") assert(all_positive([len]),"Length must be a postive value") @@ -1741,17 +1742,21 @@ module generic_threaded_rod( assert(all_positive([r1,r2]), "Must give d or both d1 and d2 as positive values") assert(is_undef(bevel1) || is_num(bevel1) || is_bool(bevel1) || bevel1=="reverse", "bevel1/bevel must be a number, boolean or \"reverse\"") assert(is_undef(bevel2) || is_num(bevel2) || is_bool(bevel2) || bevel2=="reverse", "bevel2/bevel must be a number, boolean or \"reverse\""); + sides = quantup(segs(max(r1,r2)), starts); rsc = internal? (1/cos(180/sides)) : 1; // Internal radius adjusted for faceting islop = internal? 2*get_slop() : 0; r1adj = r1 * rsc + islop; r2adj = r2 * rsc + islop; - + profbounds = pointlist_bounds(profile); + dummy4 = assert(profbounds[0].x>=-1/2 && profbounds[1].x<=1/2, + "profile's x values must lie in the interval [-1/2,1/2]") + assert(profile[0].x Date: Wed, 7 Jan 2026 19:41:25 -0500 Subject: [PATCH 2/2] code cleanup --- threading.scad | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/threading.scad b/threading.scad index 1d7350e6..3eb71753 100644 --- a/threading.scad +++ b/threading.scad @@ -1731,7 +1731,6 @@ module generic_threaded_rod( let(ind = search([lead_in_shape], _lead_in_table,0)[0]) assert(ind!=[],str("Unknown lead_in_shape, \"",lead_in_shape,"\"")) _lead_in_table[ind[0]][1]; - profbound = pointlist_bounds(profile); dummy0 = assert(all_positive([pitch]),"Thread pitch must be a positive value") assert(all_positive([len]),"Length must be a postive value") @@ -1752,7 +1751,7 @@ module generic_threaded_rod( dummy4 = assert(profbounds[0].x>=-1/2 && profbounds[1].x<=1/2, "profile's x values must lie in the interval [-1/2,1/2]") assert(profile[0].x=cutpt) [entry.x-cutpt-1/2,entry.y], for(entry=profile) if (entry.x