NPT threading fixes.

This commit is contained in:
Garth Minette 2021-06-09 18:29:29 -07:00
parent 203023b03b
commit 1670b0fa16
2 changed files with 45 additions and 24 deletions

View file

@ -208,7 +208,7 @@ module trapezoidal_threaded_rod(
prof = apply(side_mat, [ prof = apply(side_mat, [
for (thread = [-threads/2:1:threads/2-1]) let( for (thread = [-threads/2:1:threads/2-1]) let(
tang = (thread/starts) * 360 + ang, tang = (thread/starts) * 360 + ang,
hsc = hsc = internal? 1 :
abs(tang) > twist/2? 0 : abs(tang) > twist/2? 0 :
(higang1==0 && higang2==0)? 1 : (higang1==0 && higang2==0)? 1 :
lookup(tang, hig_table), lookup(tang, hig_table),
@ -225,7 +225,7 @@ module trapezoidal_threaded_rod(
]; ];
thread_vnfs = vnf_merge([ thread_vnfs = vnf_merge([
for (i=[0:1:starts-1]) for (i=[0:1:starts-1])
zrot(i*360/starts, p=vnf_vertex_array(thread_verts, reverse=left_handed)), zrot(i*360/starts, p=vnf_vertex_array(thread_verts, reverse=left_handed, style="min_edge")),
for (i=[0:1:starts-1]) let( for (i=[0:1:starts-1]) let(
rmat = zrot(i*360/starts), rmat = zrot(i*360/starts),
pts = deduplicate(list_head(thread_verts[0], len(prof3d)+1)), pts = deduplicate(list_head(thread_verts[0], len(prof3d)+1)),
@ -447,11 +447,15 @@ module threaded_nut(
// Module: npt_threaded_rod() // Module: npt_threaded_rod()
// Description: // Description:
// Constructs a standard NPT pipe threading. // Constructs a standard NPT pipe end threading. If `internal=true`, creates a mask for making
// internal pipe threads. Tapers smaller upwards if `internal=false`. Tapers smaller downwards
// if `internal=true`. If `hollow=true` and `internal=false`, then the pipe threads will be
// hollowed out into a pipe with the apropriate internal diameter.
// Arguments: // Arguments:
// d = Outer diameter of threaded rod. // size = NPT standard pipe size in inches. 1/16", 1/8", 1/4", 3/8", 1/2", 3/4", 1", 1+1/4", 1+1/2", or 2". Default: 1/2"
// left_handed = if true, create left-handed threads. Default = false // left_handed = If true, create left-handed threads. Default = false
// bevel = if true, bevel the thread ends. Default: false // bevel = If true, bevel the thread ends. Default: false
// hollow = If true, create a pipe with the correct internal diameter.
// internal = If true, make this a mask for making internal threads. // internal = If true, make this a mask for making internal threads.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER` // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
@ -467,9 +471,16 @@ module npt_threaded_rod(
size=1/2, size=1/2,
left_handed=false, left_handed=false,
bevel=false, bevel=false,
hollow=false,
internal=false, internal=false,
anchor, spin, orient anchor, spin, orient
) { ) {
assert(is_finite(size));
assert(is_bool(left_handed));
assert(is_bool(bevel));
assert(is_bool(hollow));
assert(is_bool(internal));
assert(!(internal&&hollow), "Cannot created a hollow internal threads mask.");
info_table = [ info_table = [
// Size OD len TPI // Size OD len TPI
[ 1/16, [ 0.3896, 0.308, 27 ]], [ 1/16, [ 0.3896, 0.308, 27 ]],
@ -488,8 +499,10 @@ module npt_threaded_rod(
l = 25.4 * info[0]; l = 25.4 * info[0];
d = 25.4 * info[1]; d = 25.4 * info[1];
pitch = 25.4 / info[2]; pitch = 25.4 / info[2];
r1 = get_radius(d=d, dflt=0.84 * 25.4 / 2); rr = get_radius(d=d, dflt=0.84 * 25.4 / 2);
r2 = r1 - l/32; rr2 = rr - l/32;
r1 = internal? rr2 : rr;
r2 = internal? rr : rr2;
depth = pitch * cos(30) * 5/8; depth = pitch * cos(30) * 5/8;
profile = internal? [ profile = internal? [
[-6/16, -depth/pitch], [-6/16, -depth/pitch],
@ -506,20 +519,28 @@ module npt_threaded_rod(
[ 6/16, -depth/pitch], [ 6/16, -depth/pitch],
[ 7/16, -depth/pitch*1.07] [ 7/16, -depth/pitch*1.07]
]; ];
trapezoidal_threaded_rod( attachable(anchor,spin,orient, l=l, r1=r1, r2=r2) {
d1=2*r1, d2=2*r2, l=l, difference() {
pitch=pitch, trapezoidal_threaded_rod(
thread_depth=depth, d1=2*r1, d2=2*r2, l=l,
thread_angle=30, pitch=pitch,
profile=profile, thread_depth=depth,
left_handed=left_handed, thread_angle=30,
bevel=bevel, profile=profile,
internal=internal, left_handed=left_handed,
higbee=r1*PI/2, bevel=bevel,
anchor=anchor, internal=internal,
spin=spin, higbee=r1*PI/2,
orient=orient anchor=anchor,
) children(); spin=spin,
orient=orient
);
if (hollow) {
cylinder(l=l+1, d=size*INCH, center=true);
} else nil();
}
children();
}
} }

View file

@ -946,8 +946,8 @@ function yscale(y=1, p, cp=0, planar=false) =
assert(is_bool(planar)) assert(is_bool(planar))
let( cp = is_num(cp)? [0,cp,0] : cp ) let( cp = is_num(cp)? [0,cp,0] : cp )
(planar || (!is_undef(p) && len(p)==2)) (planar || (!is_undef(p) && len(p)==2))
? scale([1,y],p=p) ? scale([1,y], cp=cp, p=p)
: scale([1,y,1],p=p); : scale([1,y,1], cp=cp, p=p);
// Function&Module: zscale() // Function&Module: zscale()