// Module: bsppfit_threaded_rod()
// Synopsis: BSPP threading with an optional male-thread clearance allowance.
// SynTags: Geom
// Topics: Threading, Screws
// See Also: bspp_threaded_rod(), generic_threaded_rod()
// Usage:
// bsppfit_threaded_rod(size, [internal=], [male_slop=], ...) [ATTACHMENTS];
// Description:
// A diverted copy of BOSL2's bspp_threaded_rod() that adds a
// male-thread clearance allowance. BOSL2 applies $slop to internal
// (female) threads only; this module adds male_slop, which reduces
// the male rod diameter by 2*male_slop (mirroring the female's
// 2*$slop on the radius) so that a printed male thread can be given
// clearance for a heterogeneous fit (e.g. a printed male into a rigid
// metal female). male_slop has no effect when internal=true, and
// male_slop=0 reproduces the upstream module exactly. All other
// behaviour is identical to bspp_threaded_rod().
// Arguments:
// size = BSP standard pipe size. 1/16, 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, 1, 1+1/8, 1+1/4, 1+3/8, 1+1/2, 1+5/8, 1+3/4, 1+7/8 or 2.
// l / length / h / height = Length of threaded rod.
// ---
// male_slop = Radial clearance allowance for EXTERNAL (male) threads; subtracts 2*male_slop from the rod diameter. No effect when internal=true. Default: 0
// left_handed = If true, create left-handed threads. Default: false
// starts = The number of lead starts. Default: 1
// internal = If true, make this a mask for making internal threads. Default: false
// bevel = Sets bevel for both ends. Set to true for default size, a number to specify a bevel size, false for no bevel, and "reverse" for an inverted bevel. Default: false for blunt start ends, true otherwise
// bevel1 = Set bevel for bottom end. Overrides bevel=.
// bevel2 = Set bevel for top end. Overrides bevel=.
// blunt_start = If true apply truncated blunt start threads at both ends. Default: true
// blunt_start1 = If true apply truncated blunt start threads bottom end.
// blunt_start2 = If true apply truncated blunt start threads top end.
// end_len = Specify the unthreaded length at the end after blunt start threads. Default: 0
// end_len1 = Specify unthreaded length at the bottom
// end_len2 = Specify unthreaded length at the top
// lead_in = Specify linear length of the lead in section of the threading with blunt start threads
// lead_in1 = Specify linear length of the lead in section of the threading at the bottom with blunt start threads
// lead_in2 = Specify linear length of the lead in section of the threading at the top with blunt start threads
// lead_in_ang = Specify angular length in degrees of the lead in section of the threading with blunt start threads
// lead_in_ang1 = Specify angular length in degrees of the lead in section of the threading at the bottom with blunt start threads
// lead_in_ang2 = Specify angular length in degrees of the lead in section of the threading at the top with blunt start threads
// lead_in_shape = Specify the shape of the thread lead in by giving a text string or function. Default: "default"
// anchor = Translate so anchor point is at origin (0,0,0). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. Default: `0`
// orient = Vector to rotate top towards, after spin. Default: `UP`
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to INTERNAL threads only.
// Examples(Med):
// bsppfit_threaded_rod(size=1/2, length=10, $fn=72);
// bsppfit_threaded_rod(size=1/2, length=10, male_slop=0.1, $fn=72);
// bsppfit_threaded_rod(size=3/4, length=10, internal=true, $slop=0.1, $fn=96);
bsppfit_dimensions = [
// Size TPI OD
[ 1/16, [ 28, 0.3041 ]],
[ 1/8, [ 28, 0.3830 ]],
[ 1/4, [ 19, 0.5180 ]],
[ 3/8, [ 19, 0.6560 ]],
[ 1/2, [ 14, 0.8250 ]],
[ 5/8, [ 14, 0.9020 ]],
[ 3/4, [ 14, 1.0410 ]],
[ 7/8, [ 14, 1.1890 ]],
[ 1, [ 11, 1.3090 ]],
[ 1+1/8, [ 11, 1.4920 ]],
[ 1+1/4, [ 11, 1.6500 ]],
[ 1+3/8, [ 11, 1.7450 ]],
[ 1+1/2, [ 11, 1.8820 ]],
[ 1+5/8, [ 11, 2.0820 ]],
[ 1+3/4, [ 11, 2.1160 ]],
[ 1+7/8, [ 11, 2.2440 ]],
[ 2, [ 11, 2.3470 ]],
];
function bsppfit_threaded_rod(
size,
left_handed=false, starts=1,
bevel,bevel1,bevel2,
internal=false, male_slop=0,
length, height,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
anchor, spin, orient
) = no_function("bsppfit_threaded_rod");
module bsppfit_threaded_rod(
size, l, h,
left_handed=false, starts=1,
bevel,bevel1,bevel2,
internal=false, male_slop=0,
length, height,
blunt_start, blunt_start1, blunt_start2,
lead_in, lead_in1, lead_in2,
lead_in_ang, lead_in_ang1, lead_in_ang2,
end_len, end_len1, end_len2,
lead_in_shape="default",
anchor, spin, orient
)
{
assert(!is_undef(size), "undefined size");
assert(is_num(size), "size is not a number");
_pitch = 0;
_diameter = 1;
index = search(size, bsppfit_dimensions);
forcefuncall = assert(len(index), str("Unsupported BSPP size ", size, "."));
p = INCH / bsppfit_dimensions[index[0]][1][_pitch];
d = INCH * bsppfit_dimensions[index[0]][1][_diameter];
theta = 55 / 2;
H = p / (2 * tan(theta)); // : fundamental triangle height
hh = 2 * H / 3; // : actual depth of the thread
e = H * sin(theta) / 6; // : rounding arc's height
r = e / (1 - sin(theta)); // : rounding arc's radius
s = hh - 2 * e; // : straight flank depth
c = tan(theta) * (H / 6 + e); // : crest's half width
pStart = [-c, -e];
pEnd = [c, -e];
vStart = [(p / 2 - tan(theta) * (H / 6 + e)), -hh + e];
vEnd = [p / 2, -hh];
segments = 4;
// right valley rounding:
valley = arc(n = segments, cp = [p / 2, -(hh - r)], points = [vStart, vEnd]);
//stroke(valley, width = 0.01, color = "cyan");
// peak rounding:
peak = arc(n = 2 * segments, cp = [0, -r], points = [pStart, pEnd]);
//stroke(peak, width = 0.01, color = "cyan");
profile = scale(1 / p, concat(reverse(xflip(valley)), peak, valley));
//stroke(profile, width = 0.01, color = "cyan");
generic_threaded_rod(
d = d - 2*male_slop, length = length, height = height, h=h, l=l,
pitch = p, profile = profile,
left_handed=left_handed,
bevel=bevel,bevel1=bevel1,bevel2=bevel2,
internal=internal,
blunt_start=blunt_start, blunt_start1=blunt_start1, blunt_start2=blunt_start2,
lead_in=lead_in, lead_in1=lead_in1, lead_in2=lead_in2, lead_in_shape=lead_in_shape,
lead_in_ang=lead_in_ang, lead_in_ang1=lead_in_ang1, lead_in_ang2=lead_in_ang2,
end_len=end_len, end_len1=end_len1, end_len2=end_len2,
anchor=anchor,
spin=spin,starts=starts,
orient=orient
)
children();
Hello,
I'm working on BSPP fittings and I encounter an issue that I would
like to amend in the
bspp_threaded_rodmodule by adding themale_slop argument, with an initial value of 0mm.
The rationale of this is the following: when using a 3D printed male
threaded rod which must be inserted in a brass female commercial
fitting we cannot adjust the female thread but we can adjust the male
thread which we are printing. This is the pending of the slop
applied to female/internal threads for male threads.
I think that the same can happen for other thread type but my
request is limited to BSPP.
You'll find bellow the modified code; the modifications are quite
simple:
generic_threaded_rodmodule where we subtractfrom the diameter twice the male slop.