make slop undef and add get_slop()

add no_children in places
This commit is contained in:
Adrian Mariano 2022-04-11 22:18:52 -04:00
parent f75ff907c7
commit 82b4b284a9
12 changed files with 51 additions and 34 deletions

View file

@ -1309,7 +1309,8 @@ function bezier_vnf_degenerate_patch(patch, splinesteps=16, reverse=false, retur
// [ 5, 10], [ 0, 10] // [ 5, 10], [ 0, 10]
// ]; // ];
// debug_bezier(bez, N=3, width=0.5); // debug_bezier(bez, N=3, width=0.5);
module debug_bezier(bezpath, width=1, N=3) { module debug_bezier(bezpath, width=1, N=3) {
no_children($children);
assert(is_path(bezpath)); assert(is_path(bezpath));
assert(is_int(N)); assert(is_int(N));
assert(len(bezpath)%N == 1, str("A degree ",N," bezier path shound have a multiple of ",N," points in it, plus 1.")); assert(len(bezpath)%N == 1, str("A degree ",N," bezier path shound have a multiple of ",N," points in it, plus 1."));
@ -1372,6 +1373,7 @@ module debug_bezier(bezpath, width=1, N=3) {
// debug_bezier_patches(patches=[patch1, patch2], splinesteps=8, showcps=true); // debug_bezier_patches(patches=[patch1, patch2], splinesteps=8, showcps=true);
module debug_bezier_patches(patches=[], size, splinesteps=16, showcps=true, showdots=false, showpatch=true, convexity=10, style="default") module debug_bezier_patches(patches=[], size, splinesteps=16, showcps=true, showdots=false, showpatch=true, convexity=10, style="default")
{ {
no_children($children);
assert(is_undef(size)||is_num(size)); assert(is_undef(size)||is_num(size));
assert(is_int(splinesteps) && splinesteps>0); assert(is_int(splinesteps) && splinesteps>0);
assert(is_list(patches) && all([for (patch=patches) is_bezier_patch(patch)])); assert(is_list(patches) && all([for (patch=patches) is_bezier_patch(patch)]));

View file

@ -22,6 +22,11 @@ _UNDEF="LRG+HX7dy89RyHvDlAKvb9Y04OTuaikpx205CTh8BSI";
// `2*$slop` to each side. This should be done for both X and Y axes. The Z axis will require a // `2*$slop` to each side. This should be done for both X and Y axes. The Z axis will require a
// slop that depends on your layer height and bridging settings, and hole sizes. We leave that as // slop that depends on your layer height and bridging settings, and hole sizes. We leave that as
// a more complicated exercise for the user. // a more complicated exercise for the user.
// .
// Note that the slop value is accessed using the {{get_slop()}} function. This function provides
// the default value of 0 if you have not set `$slop`. This approach makes it possible for you to
// set `$slop` in your programs without experiencing peculiar OpenSCAD issues having to do with multiple
// definitions of the variable. If you write code that uses `$slop` be sure to reference it using {{get_slop()}}.
// DefineHeader(NumList): Calibration // DefineHeader(NumList): Calibration
// Calibration: To calibrate the `$slop` value for your printer, follow this procedure: // Calibration: To calibrate the `$slop` value for your printer, follow this procedure:
// Print the Slop Calibration part from the example below. // Print the Slop Calibration part from the example below.
@ -92,7 +97,14 @@ _UNDEF="LRG+HX7dy89RyHvDlAKvb9Y04OTuaikpx205CTh8BSI";
// text("gap", size=1.5, halign="center"); // text("gap", size=1.5, halign="center");
// } // }
// } // }
$slop = 0.0;
// Function: get_slop()
// Usage:
// slop = get_slop();
// Description:
// Returns the current $slop value, or the default value if the user did not set $slop.
// Always acess the `$slop` variable using this function.
function get_slop() = is_undef($slop) ? 0 : $slop;
// Constant: INCH // Constant: INCH

View file

@ -204,11 +204,11 @@ module cubetruss_clip(extents=1, size, strut, clipthick, anchor=CENTER, spin=0,
} }
} }
fwd(strut*3/2) { fwd(strut*3/2) {
cube([$slop, strut*3, size], center=true); cube([get_slop(), strut*3, size], center=true);
} }
} }
right($slop/2+0.01) { right(get_slop()/2+0.01) {
fwd(strut*1.25+$slop) { fwd(strut*1.25+get_slop()) {
yrot(-90) prismoid([clipheight-cliplen*2, strut/2], [clipheight-cliplen*2-2*clipsize, strut/2], h=clipsize+0.01); yrot(-90) prismoid([clipheight-cliplen*2, strut/2], [clipheight-cliplen*2-2*clipsize, strut/2], h=clipsize+0.01);
} }
} }
@ -268,7 +268,7 @@ module cubetruss_foot(w=1, size, strut, clipthick, anchor=CENTER, spin=0, orient
} }
// Horiz Wall Clips // Horiz Wall Clips
up(clipthick+strut+$slop*2) { up(clipthick+strut+get_slop()*2) {
xcopies(w*(size-strut)+strut) { xcopies(w*(size-strut)+strut) {
prismoid([clipsize*2, size/3.5], [0.1, size/3.5], h=clipsize*3, anchor=BOT); prismoid([clipsize*2, size/3.5], [0.1, size/3.5], h=clipsize*3, anchor=BOT);
} }
@ -280,19 +280,19 @@ module cubetruss_foot(w=1, size, strut, clipthick, anchor=CENTER, spin=0, orient
difference() { difference() {
// Start with octagon to fit sides. // Start with octagon to fit sides.
up(clipthick-0.01) { up(clipthick-0.01) {
zrot(180/8) cylinder(h=strut, d1=cyld-4*$slop, d2=cyld-4*$slop-1, center=false, $fn=8); zrot(180/8) cylinder(h=strut, d1=cyld-4*get_slop(), d2=cyld-4*get_slop()-1, center=false, $fn=8);
} }
// Bevel to fit. // Bevel to fit.
up(clipthick+strut) { up(clipthick+strut) {
ycopies(size-2*strut-4*$slop) { ycopies(size-2*strut-4*get_slop()) {
chamfer_edge_mask(l=size-strut, chamfer=strut*2/3, orient=RIGHT); chamfer_edge_mask(l=size-strut, chamfer=strut*2/3, orient=RIGHT);
} }
} }
// Cut out X for possible top mount. // Cut out X for possible top mount.
zrot_copies([-45, 45]) { zrot_copies([-45, 45]) {
cube([size*3, strut/sqrt(2)+2*$slop, size*3], center=true); cube([size*3, strut/sqrt(2)+2*get_slop(), size*3], center=true);
} }
} }
} }
@ -354,7 +354,7 @@ module cubetruss_joiner(w=1, vert=true, size, strut, clipthick, anchor=CENTER, s
// Vert Wall Clips // Vert Wall Clips
up(size/2) { up(size/2) {
xflip_copy(offset=(w*(size-strut)+strut+0.02)/2) { xflip_copy(offset=(w*(size-strut)+strut+0.02)/2) {
yflip_copy(offset=strut+$slop/2) { yflip_copy(offset=strut+get_slop()/2) {
yrot(-90) { yrot(-90) {
back_half() { back_half() {
prismoid([size/3.5, clipthick*2], [size/3.5-4*2*clipsize, 0.1], h=2*clipsize, anchor=BOT); prismoid([size/3.5, clipthick*2], [size/3.5-4*2*clipsize, 0.1], h=2*clipsize, anchor=BOT);
@ -393,15 +393,15 @@ module cubetruss_uclip(dual=true, size, strut, clipthick, anchor=CENTER, spin=0,
strut = is_undef(strut)? $cubetruss_strut_size : strut; strut = is_undef(strut)? $cubetruss_strut_size : strut;
clipthick = is_undef(clipthick)? $cubetruss_clip_thickness : clipthick; clipthick = is_undef(clipthick)? $cubetruss_clip_thickness : clipthick;
clipsize = 0.5; clipsize = 0.5;
s = [(dual?2:1)*strut+2*clipthick+$slop, strut+2*clipthick, size/3.5]; s = [(dual?2:1)*strut+2*clipthick+get_slop(), strut+2*clipthick, size/3.5];
attachable(anchor,spin,orient, size=s) { attachable(anchor,spin,orient, size=s) {
union() { union() {
difference() { difference() {
cube(s, center=true); cube(s, center=true);
back(clipthick) cube([(dual?2:1)*strut+$slop, strut+2*clipthick, size+1], center=true); back(clipthick) cube([(dual?2:1)*strut+get_slop(), strut+2*clipthick, size+1], center=true);
} }
back((strut+$slop)/2) { back((strut+get_slop())/2) {
xflip_copy(offset=(dual?1:0.5)*strut+$slop/2) { xflip_copy(offset=(dual?1:0.5)*strut+get_slop()/2) {
yrot(-90) { yrot(-90) {
back_half() { back_half() {
prismoid([size/3.5, clipthick*1.87], [size/3.5, 0.1], h=clipsize, anchor=BOT); prismoid([size/3.5, clipthick*1.87], [size/3.5, 0.1], h=clipsize, anchor=BOT);

View file

@ -1127,6 +1127,7 @@ function _turtle_command(command, parm, parm2, state, index) =
// ); // );
module debug_polygon(points, paths, vertices=true, edges=true, convexity=2, size=1) module debug_polygon(points, paths, vertices=true, edges=true, convexity=2, size=1)
{ {
no_children($children);
paths = is_undef(paths)? [count(points)] : paths = is_undef(paths)? [count(points)] :
is_num(paths[0])? [paths] : is_num(paths[0])? [paths] :
paths; paths;

View file

@ -1202,6 +1202,7 @@ module _gear_tooth_profile(
center = false, center = false,
mod mod
) { ) {
no_children($children);
pitch = is_undef(mod) ? pitch : pitch_value(mod); pitch = is_undef(mod) ? pitch : pitch_value(mod);
r = _root_radius(pitch, teeth, clearance, interior); r = _root_radius(pitch, teeth, clearance, interior);
fwd(r) fwd(r)

View file

@ -56,7 +56,7 @@
// } // }
module apply_folding_hinges_and_snaps(thick, foldangle=90, hinges=[], snaps=[], sockets=[], snaplen=5, snapdiam=5, hingegap=undef, layerheight=0.2) module apply_folding_hinges_and_snaps(thick, foldangle=90, hinges=[], snaps=[], sockets=[], snaplen=5, snapdiam=5, hingegap=undef, layerheight=0.2)
{ {
hingegap = default(hingegap, layerheight)+2*$slop; hingegap = default(hingegap, layerheight)+2*get_slop();
difference() { difference() {
children(); children();
for (hinge = hinges) { for (hinge = hinges) {
@ -111,7 +111,7 @@ module apply_folding_hinges_and_snaps(thick, foldangle=90, hinges=[], snaps=[],
// folding_hinge_mask(l=100, thick=3, foldangle=60); // folding_hinge_mask(l=100, thick=3, foldangle=60);
module folding_hinge_mask(l, thick, layerheight=0.2, foldangle=90, hingegap=undef, anchor=CENTER, spin=0, orient=UP) module folding_hinge_mask(l, thick, layerheight=0.2, foldangle=90, hingegap=undef, anchor=CENTER, spin=0, orient=UP)
{ {
hingegap = default(hingegap, layerheight)+2*$slop; hingegap = default(hingegap, layerheight)+2*get_slop();
size = [l, hingegap, 2*thick]; size = [l, hingegap, 2*thick];
size2 = [l, hingegap+2*thick*tan(foldangle/2)]; size2 = [l, hingegap+2*thick*tan(foldangle/2)];
attachable(anchor,spin,orient, size=size, size2=size2) { attachable(anchor,spin,orient, size=size, size2=size2) {
@ -141,7 +141,7 @@ module folding_hinge_mask(l, thick, layerheight=0.2, foldangle=90, hingegap=unde
// snap_lock(thick=3, foldangle=60); // snap_lock(thick=3, foldangle=60);
module snap_lock(thick, snaplen=5, snapdiam=5, layerheight=0.2, foldangle=90, hingegap=undef, anchor=CENTER, spin=0, orient=UP) module snap_lock(thick, snaplen=5, snapdiam=5, layerheight=0.2, foldangle=90, hingegap=undef, anchor=CENTER, spin=0, orient=UP)
{ {
hingegap = default(hingegap, layerheight)+2*$slop; hingegap = default(hingegap, layerheight)+2*get_slop();
snap_x = (snapdiam/2) / tan(foldangle/2) + (thick-2*layerheight)/tan(foldangle/2) + hingegap/2; snap_x = (snapdiam/2) / tan(foldangle/2) + (thick-2*layerheight)/tan(foldangle/2) + hingegap/2;
size = [snaplen, snapdiam, 2*thick]; size = [snaplen, snapdiam, 2*thick];
attachable(anchor,spin,orient, size=size) { attachable(anchor,spin,orient, size=size) {
@ -176,12 +176,12 @@ module snap_lock(thick, snaplen=5, snapdiam=5, layerheight=0.2, foldangle=90, hi
// snap_socket(thick=3, foldangle=60); // snap_socket(thick=3, foldangle=60);
module snap_socket(thick, snaplen=5, snapdiam=5, layerheight=0.2, foldangle=90, hingegap=undef, anchor=CENTER, spin=0, orient=UP) module snap_socket(thick, snaplen=5, snapdiam=5, layerheight=0.2, foldangle=90, hingegap=undef, anchor=CENTER, spin=0, orient=UP)
{ {
hingegap = default(hingegap, layerheight)+2*$slop; hingegap = default(hingegap, layerheight)+2*get_slop();
snap_x = (snapdiam/2) / tan(foldangle/2) + (thick-2*layerheight)/tan(foldangle/2) + hingegap/2; snap_x = (snapdiam/2) / tan(foldangle/2) + (thick-2*layerheight)/tan(foldangle/2) + hingegap/2;
size = [snaplen, snapdiam, 2*thick]; size = [snaplen, snapdiam, 2*thick];
attachable(anchor,spin,orient, size=size) { attachable(anchor,spin,orient, size=size) {
fwd(snap_x) { fwd(snap_x) {
zrot_copies([0,180], r=snaplen+$slop) { zrot_copies([0,180], r=snaplen+get_slop()) {
diff("divot") diff("divot")
cube([snaplen, snapdiam, snapdiam/2+thick], anchor=BOT) { cube([snaplen, snapdiam, snapdiam/2+thick], anchor=BOT) {
attach(TOP) xcyl(l=snaplen, d=snapdiam, $fn=16); attach(TOP) xcyl(l=snaplen, d=snapdiam, $fn=16);

View file

@ -107,7 +107,7 @@ module half_joiner(h=20, w=10, l=10, a=30, screwsize=undef, guides=true, anchor=
cube([w+1, guide_width+1, h+1], anchor=FWD+BOT); cube([w+1, guide_width+1, h+1], anchor=FWD+BOT);
// Clear sides // Clear sides
xcopies(2*w*2/3-$slop*2) { xcopies(2*w*2/3-get_slop()*2) {
cube([w, guide_width, h/3], center=true); cube([w, guide_width, h/3], center=true);
fwd(guide_width/2) fwd(guide_width/2)
yrot_copies(n=2) yrot_copies(n=2)
@ -119,7 +119,7 @@ module half_joiner(h=20, w=10, l=10, a=30, screwsize=undef, guides=true, anchor=
// Guide ridges. // Guide ridges.
if (guides == true) { if (guides == true) {
xcopies(w/3-$slop*2) { xcopies(w/3-get_slop()*2) {
// Guide ridge. // Guide ridge.
fwd(0.05/2) { fwd(0.05/2) {
scale([0.75, 1, 2]) yrot(45) scale([0.75, 1, 2]) yrot(45)
@ -325,7 +325,7 @@ module joiner_pair_clear(spacing=100, n=2, h=40, w=10, a=30, clearance=0, overla
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // 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` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// $slop = Printer specific slop value to make parts fit more closely. // get_slop() = Printer specific slop value to make parts fit more closely.
// Example(FlatSpin,VPD=200): // Example(FlatSpin,VPD=200):
// joiner_pair(spacing=50, l=10); // joiner_pair(spacing=50, l=10);
// Examples: // Examples:
@ -540,7 +540,7 @@ module dovetail(gender, width, height, slide, h, w, angle, slope, taper, back_wi
assert(count3<=1 || (radius==0 && chamfer==0), "Do not specify both chamfer and radius"); assert(count3<=1 || (radius==0 && chamfer==0), "Do not specify both chamfer and radius");
slope = is_def(slope) ? slope : slope = is_def(slope) ? slope :
is_def(angle) ? 1/tan(angle) : 6; is_def(angle) ? 1/tan(angle) : 6;
extra_slop = gender == "female" ? 2*$slop : 0; extra_slop = gender == "female" ? 2*get_slop() : 0;
width = w + extra_slop; width = w + extra_slop;
height = h + extra_slop; height = h + extra_slop;
back_width = u_add(back_width, extra_slop); back_width = u_add(back_width, extra_slop);

View file

@ -469,9 +469,9 @@ module nema34_stepper(h=75, shaft=12.7, shaft_len=32, anchor=TOP, spin=0, orient
module nema_mount_holes(size=17, depth=5, l=5, anchor=CENTER, spin=0, orient=UP) module nema_mount_holes(size=17, depth=5, l=5, anchor=CENTER, spin=0, orient=UP)
{ {
motor_width = nema_motor_width(size); motor_width = nema_motor_width(size);
plinth_diam = nema_motor_plinth_diam(size)+$slop; plinth_diam = nema_motor_plinth_diam(size)+get_slop();
screw_spacing = nema_motor_screw_spacing(size); screw_spacing = nema_motor_screw_spacing(size);
screw_size = nema_motor_screw_size(size)+$slop; screw_size = nema_motor_screw_size(size)+get_slop();
anchors = [ anchors = [
named_anchor("screw1", [+screw_spacing/2, +screw_spacing/2, depth/2]), named_anchor("screw1", [+screw_spacing/2, +screw_spacing/2, depth/2]),

View file

@ -432,13 +432,13 @@ module partition_mask(l=100, w=100, h=100, cutsize=10, cutpath="jigsaw", gap=0,
cutsize = is_vector(cutsize)? point2d(cutsize) : [cutsize*2, cutsize]; cutsize = is_vector(cutsize)? point2d(cutsize) : [cutsize*2, cutsize];
path = _partition_cutpath(l, h, cutsize, cutpath, gap); path = _partition_cutpath(l, h, cutsize, cutpath, gap);
midpath = select(path,1,-2); midpath = select(path,1,-2);
sizepath = concat([path[0]+[-$slop,0]], midpath, [last(path)+[$slop,0]], [[+(l/2+$slop), (w+$slop)*(inverse?-1:1)], [-(l/2+$slop), (w+$slop)*(inverse?-1:1)]]); sizepath = concat([path[0]+[-get_slop(),0]], midpath, [last(path)+[get_slop(),0]], [[+(l/2+get_slop()), (w+get_slop())*(inverse?-1:1)], [-(l/2+get_slop()), (w+get_slop())*(inverse?-1:1)]]);
bnds = pointlist_bounds(sizepath); bnds = pointlist_bounds(sizepath);
fullpath = concat(path, [[last(path).x, w*(inverse?-1:1)], [path[0].x, w*(inverse?-1:1)]]); fullpath = concat(path, [[last(path).x, w*(inverse?-1:1)], [path[0].x, w*(inverse?-1:1)]]);
attachable(anchor,spin,orient, size=point3d(bnds[1]-bnds[0],h)) { attachable(anchor,spin,orient, size=point3d(bnds[1]-bnds[0],h)) {
linear_extrude(height=h, center=true, convexity=10) { linear_extrude(height=h, center=true, convexity=10) {
intersection() { intersection() {
offset(delta=-$slop) polygon(fullpath); offset(delta=-get_slop()) polygon(fullpath);
square([l, w*2], center=true); square([l, w*2], center=true);
} }
} }
@ -483,7 +483,7 @@ module partition_cut_mask(l=100, h=100, cutsize=10, cutpath="jigsaw", gap=0, anc
path = _partition_cutpath(l, h, cutsize, cutpath, gap); path = _partition_cutpath(l, h, cutsize, cutpath, gap);
attachable(anchor,spin,orient, size=[l,cutsize.y,h]) { attachable(anchor,spin,orient, size=[l,cutsize.y,h]) {
linear_extrude(height=h, center=true, convexity=10) { linear_extrude(height=h, center=true, convexity=10) {
stroke(path, width=max(0.1, $slop*2)); stroke(path, width=max(0.1, get_slop()*2));
} }
children(); children();
} }

View file

@ -164,6 +164,7 @@ module torx_mask(size, l=5, center, anchor, spin=0, orient=UP) {
// Example(2D): // Example(2D):
// torx_mask2d(size=30, $fa=1, $fs=1); // torx_mask2d(size=30, $fa=1, $fs=1);
module torx_mask2d(size) { module torx_mask2d(size) {
no_children($children);
od = torx_diam(size); od = torx_diam(size);
id = _torx_inner_diam(size); id = _torx_inner_diam(size);
tip = _torx_tip_radius(size); tip = _torx_tip_radius(size);
@ -360,7 +361,7 @@ module robertson_mask(size, extra=1, ang=2.5) {
Fmax = [0.038, 0.065, 0.075, 0.095, 0.100][size]; Fmax = [0.038, 0.065, 0.075, 0.095, 0.100][size];
F = (Fmin + Fmax) / 2 * INCH; F = (Fmin + Fmax) / 2 * INCH;
h = T + extra; h = T + extra;
Mslop=M+2*$slop; Mslop=M+2*get_slop();
down(T) { down(T) {
intersection(){ intersection(){
Mtop = Mslop + 2*adj_ang_to_opp(F+extra,ang); Mtop = Mslop + 2*adj_ang_to_opp(F+extra,ang);

View file

@ -41,16 +41,16 @@ module slider(l=30, w=10, h=10, base=10, wall=5, ang=30, anchor=BOTTOM, spin=0,
zrot(90) zrot(90)
down(base+h/2) { down(base+h/2) {
// Base // Base
cuboid([full_width, l, base-$slop], chamfer=2, edges=[FRONT,BACK], except_edges=BOT, anchor=BOTTOM); cuboid([full_width, l, base-get_slop()], chamfer=2, edges=[FRONT,BACK], except_edges=BOT, anchor=BOTTOM);
// Wall // Wall
xflip_copy(offset=w/2+$slop) { xflip_copy(offset=w/2+get_slop()) {
cuboid([wall, l, full_height], chamfer=2, edges=RIGHT, except_edges=BOT, anchor=BOTTOM+LEFT); cuboid([wall, l, full_height], chamfer=2, edges=RIGHT, except_edges=BOT, anchor=BOTTOM+LEFT);
} }
// Sliders // Sliders
up(base+h/2) { up(base+h/2) {
xflip_copy(offset=w/2+$slop+0.02) { xflip_copy(offset=w/2+get_slop()+0.02) {
bev_h = h/2*tan(ang); bev_h = h/2*tan(ang);
prismoid([h, l], [0, l-w], h=bev_h+0.01, orient=LEFT, anchor=BOT); prismoid([h, l], [0, l-w], h=bev_h+0.01, orient=LEFT, anchor=BOT);
} }

View file

@ -539,7 +539,7 @@ module acme_threaded_nut(
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER` // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // 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` // 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.p // $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
// Example(2D): The straight gray rectangle reveals the tapered threads. // Example(2D): The straight gray rectangle reveals the tapered threads.
// projection(cut=true) npt_threaded_rod(size=1/4, orient=BACK); // projection(cut=true) npt_threaded_rod(size=1/4, orient=BACK);
// right(.533*INCH/2) color("gray") rect([2,0.5946*INCH],anchor=LEFT); // right(.533*INCH/2) color("gray") rect([2,0.5946*INCH],anchor=LEFT);
@ -1075,7 +1075,7 @@ module generic_threaded_rod(
r2 = get_radius(d1=d2, d=d); r2 = get_radius(d1=d2, d=d);
sides = quantup(segs(max(r1,r2)), starts); sides = quantup(segs(max(r1,r2)), starts);
rsc = internal? (1/cos(180/sides)) : 1; rsc = internal? (1/cos(180/sides)) : 1;
islop = internal? 2*$slop : 0; islop = internal? 2*get_slop() : 0;
_r1 = r1 * rsc + islop; _r1 = r1 * rsc + islop;
_r2 = r2 * rsc + islop; _r2 = r2 * rsc + islop;
threads = quantup(l/pitch+2,1); // Was quantup(1/pitch+2,2*starts); threads = quantup(l/pitch+2,1); // Was quantup(1/pitch+2,2*starts);