discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

3d printing bolts at an angle with modeled support

JB
Jon Bondy
Sat, Aug 10, 2024 4:37 PM

Interesting idea.  I assume that the dingus under the bolt is custom
support.  It seems very far away from the part: does it work?

Jon

On 8/9/2024 10:35 PM, Todd Allen via Discuss wrote:

It is easiest to print bolts vertically standing on their heads but
tensile strength is then maximally impacted by layer adhesion. 
Printing at a significant angle from vertical can achieve much better
tensile strength but requires support or cutting the bolt to create a
flat surface to lay on the print bed to print horizontally.  There are
many cases where cutting the bolt is not a good option and for those
cases I've found it fussy to generate support in a slicer that
contacts the bolt precisely as I want to allow for clean easy support
removal.

Here's an OpenSCAD script for creating bolts to be printed at an angle
with integrated support that I've found helpful for rapidly knocking
out a variety of fasteners with good tensile strength that take
trivial clean up effort to be ready for use.  It uses
BOSL2/screws.scad to create bolts.  It's quite basic with little
polish and can require tweaking of a few parameters to get best
results but still I've found it very useful and think others might
too.  The technique I used to generate the support could readily be
adapted to a wide range of other objects.

If anyone knows of better approaches to printing bolts or generating
support I would love to hear about it.

include <BOSL2/std.scad>
include <BOSL2/screws.scad>

$fn= $preview ? 12 : 256;
eps = 0.001;

// set trimscale sufficiently large to shave enough of the threads to
eliminate or minimize producing isolated blobs when sliced that don't
print well
// set ulength=0 for no chamfer to threaded shaft
// use x0_fudge to adjust where print_bolt() support starts on x axis
// use z_fudge to adjust z height of print_bolt()
module setenv_bolt(name, head="hex", drive="none",
    ulength=undef, nut_threads=2.5, nut_diameter=0,
    tolerance="6g", trimscale=1.0, slop=0.06,
    zrot, x0_fudge=0, z_fudge=0,
    support_thickness, support_gap = 0.15, support_ears_d,
support_ears_z = 0.2)
{
    spec = screw_info(name);
    $name = name;
    $head = head;
    $drive = drive;
    $p = struct_val(spec, "pitch");
    $l = struct_val(spec, "length");
    $d = struct_val(spec, "diameter");
    $nh = $pnut_threads+1.5;
    $nd = nut_diameter ? nut_diameter : $d
1.2+4.0;

    $nut_spec = struct_set(spec, [
        "length", $nh+2eps,
        "thread_len", $nh+2
eps
        ]);

    $tolerance = tolerance;
    $trimscale = trimscale;
    $ul = is_undef(ulength) ? $p*0.5 : ulength; // should also add in
amount tolerance spec undersizes threaded minor radius
    $tl = $l - $ul;
    $bolt_spec = struct_set(screw_info(name, head=head, drive=drive), [
        "thread_len", $tl
        ]);
    echo($bolt_spec = $bolt_spec);

    $hs = struct_val($bolt_spec, "head_size", $d);
    $hh = struct_val($bolt_spec, "head_height", 0);

    $slop = slop;   // $slop is parameter of BOSL2 screw_hole()

    // align hex head to rest on a flat when rotated about Y axis for
printing as headsize is across flats
    // may want default angles for drive types too
    auto_zrot = ($head=="hex") ? 90 : 60;
    $bolt_zrot = is_undef(zrot) ? auto_zrot : zrot;

    $x0_fudge = x0_fudge;
    $z_fudge = z_fudge;
    $support_thickness = is_undef(support_thickness) ? 0.9+0.1*$d:
support_thickness;
    $support_gap = support_gap;
    $support_ears_d = is_undef(support_ears_d) ? 3+$d : support_ears_d;
    $support_ears_z = support_ears_z;

    children();
}

module bolt() {
    zrot($bolt_zrot) screw(spec=$bolt_spec, tolerance=$tolerance,
orient=DOWN, anchor=TOP);
}

module shank_chamfer_mask(od, c) {
    difference() {
        zcyl(h=c, d=od+10eps, anchor=TOP);
        up(eps) zcyl(h=c+2
eps, d=od-2*c, chamfer1=-c, anchor=TOP);
        }
}

// bolt tweaked for printing with threads trimmed and end of
unthreaded shank chamfered
module printable_bolt(angle=0, z_shift=0) {
    up(z_shift) yrot(angle) intersection() {
        if ($ul>0) difference() {
            bolt();
            up($hh+$l-$tl+eps) shank_chamfer_mask($d, $p0.5);
            }
        else bolt();
        union() {
            // head
            zcyl(l=$hh+$l-$tl, d=$hs+3, anchor=BOT);
            // trimmed shaft
            up($hh+$l-$tl-eps)
cuboid([$d-$p
$trimscale,$d,$tl+eps],anchor=BOT);
            }
        }
}

module print_bolt(angle=60) {
    bolt_length = $hh + $l;
    support_x0 = $x0_fudge + cos(angle) * $hh;
    support_x1 = sin(angle) * bolt_length + cos(angle)$d0.50.40;
    support_z = cos(angle) * bolt_length - sin(angle)
$d0.4;
    z_shift = (angle<=90) ? $z_fudge+sin(angle)
$hs0.5 :
$z_fudge+max(sin(angle)
$hs0.5, sin(angle)$hs0.5-cos(angle$hh),
-cos(angle)bolt_length+sin(angle)$d0.4);
    matrix_from_projection = frame_map(x=RIGHT, y=UP);
    matrix_to_projection = matrix_inverse(matrix_from_projection);
    union() {
        // support for the bolt
        multmatrix(matrix_from_projection) linear_extrude(height =
$support_thickness, center=true)
        difference() {
            polygon([[support_x0,0], [support_x1,0],
[support_x1,support_z+z_shift], [support_x0,z_shift]]);
            offset(r=$support_gap) projection(cut=true)
multmatrix(matrix_to_projection) printable_bolt(angle, z_shift);
            }
        // mouse ears for the support
for(x=[$support_ears_d
0.5,support_x1-$support_ears_d*0.5+0.25])
right(x) zcyl(h=$support_ears_z, d=$support_ears_d, anchor=BOT);
        // the bolt
        printable_bolt(angle, z_shift);
        }
}

module nut() {
    difference() {
        zcyl(h=$nh, d=$nd, chamfer=$nh0.075, $fn=6, circum=true,
anchor=BOTTOM);
        down (eps) screw_hole($nut_spec, thread=true,
counterbore=false, bevel=true, anchor=BOTTOM); // , l=$nh+2
eps
    }
}

// use trimscale=0.0 in setenv_bolt() for untrimmed thread
module inspect_bolt() {
    linear_extrude(height = 1)
    projection(cut=true) xrot(-90) {
        printable_bolt();
        up($hh + $l - $nh) nut();
        }
}

// EXAMPLES
/*
setenv_bolt("M5,6", "hex", trimscale=0.9)
    print_bolt();

setenv_bolt("M4x0.8,8", head="button", drive="hex", ulength=0,
trimscale=1.05, z_fudge=-0.75, x0_fudge=0.5)
    print_bolt(angle=53.4);

setenv_bolt("M5,6", "hex", trimscale=0.9)
    nut();
//  inspect_bolt();
//  printable_bolt();
*/


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

Interesting idea.  I assume that the dingus under the bolt is custom support.  It seems very far away from the part: does it work? Jon On 8/9/2024 10:35 PM, Todd Allen via Discuss wrote: > It is easiest to print bolts vertically standing on their heads but > tensile strength is then maximally impacted by layer adhesion.  > Printing at a significant angle from vertical can achieve much better > tensile strength but requires support or cutting the bolt to create a > flat surface to lay on the print bed to print horizontally.  There are > many cases where cutting the bolt is not a good option and for those > cases I've found it fussy to generate support in a slicer that > contacts the bolt precisely as I want to allow for clean easy support > removal. > > Here's an OpenSCAD script for creating bolts to be printed at an angle > with integrated support that I've found helpful for rapidly knocking > out a variety of fasteners with good tensile strength that take > trivial clean up effort to be ready for use.  It uses > BOSL2/screws.scad to create bolts.  It's quite basic with little > polish and can require tweaking of a few parameters to get best > results but still I've found it very useful and think others might > too.  The technique I used to generate the support could readily be > adapted to a wide range of other objects. > > If anyone knows of better approaches to printing bolts or generating > support I would love to hear about it. > > include <BOSL2/std.scad> > include <BOSL2/screws.scad> > > $fn= $preview ? 12 : 256; > eps = 0.001; > > // set trimscale sufficiently large to shave enough of the threads to > eliminate or minimize producing isolated blobs when sliced that don't > print well > // set ulength=0 for no chamfer to threaded shaft > // use x0_fudge to adjust where print_bolt() support starts on x axis > // use z_fudge to adjust z height of print_bolt() > module setenv_bolt(name, head="hex", drive="none", >     ulength=undef, nut_threads=2.5, nut_diameter=0, >     tolerance="6g", trimscale=1.0, slop=0.06, >     zrot, x0_fudge=0, z_fudge=0, >     support_thickness, support_gap = 0.15, support_ears_d, > support_ears_z = 0.2) > { >     spec = screw_info(name); >     $name = name; >     $head = head; >     $drive = drive; >     $p = struct_val(spec, "pitch"); >     $l = struct_val(spec, "length"); >     $d = struct_val(spec, "diameter"); >     $nh = $p*nut_threads+1.5; >     $nd = nut_diameter ? nut_diameter : $d*1.2+4.0; > >     $nut_spec = struct_set(spec, [ >         "length", $nh+2*eps, >         "thread_len", $nh+2*eps >         ]); > >     $tolerance = tolerance; >     $trimscale = trimscale; >     $ul = is_undef(ulength) ? $p*0.5 : ulength; // should also add in > amount tolerance spec undersizes threaded minor radius >     $tl = $l - $ul; >     $bolt_spec = struct_set(screw_info(name, head=head, drive=drive), [ >         "thread_len", $tl >         ]); >     echo($bolt_spec = $bolt_spec); > >     $hs = struct_val($bolt_spec, "head_size", $d); >     $hh = struct_val($bolt_spec, "head_height", 0); > >     $slop = slop;   // $slop is parameter of BOSL2 screw_hole() > >     // align hex head to rest on a flat when rotated about Y axis for > printing as headsize is across flats >     // may want default angles for drive types too >     auto_zrot = ($head=="hex") ? 90 : 60; >     $bolt_zrot = is_undef(zrot) ? auto_zrot : zrot; > >     $x0_fudge = x0_fudge; >     $z_fudge = z_fudge; >     $support_thickness = is_undef(support_thickness) ? 0.9+0.1*$d: > support_thickness; >     $support_gap = support_gap; >     $support_ears_d = is_undef(support_ears_d) ? 3+$d : support_ears_d; >     $support_ears_z = support_ears_z; > >     children(); > } > > module bolt() { >     zrot($bolt_zrot) screw(spec=$bolt_spec, tolerance=$tolerance, > orient=DOWN, anchor=TOP); > } > > module shank_chamfer_mask(od, c) { >     difference() { >         zcyl(h=c, d=od+10*eps, anchor=TOP); >         up(eps) zcyl(h=c+2*eps, d=od-2*c, chamfer1=-c, anchor=TOP); >         } > } > > // bolt tweaked for printing with threads trimmed and end of > unthreaded shank chamfered > module printable_bolt(angle=0, z_shift=0) { >     up(z_shift) yrot(angle) intersection() { >         if ($ul>0) difference() { >             bolt(); >             up($hh+$l-$tl+eps) shank_chamfer_mask($d, $p*0.5); >             } >         else bolt(); >         union() { >             // head >             zcyl(l=$hh+$l-$tl, d=$hs+3, anchor=BOT); >             // trimmed shaft >             up($hh+$l-$tl-eps) > cuboid([$d-$p*$trimscale,$d,$tl+eps],anchor=BOT); >             } >         } > } > > module print_bolt(angle=60) { >     bolt_length = $hh + $l; >     support_x0 = $x0_fudge + cos(angle) * $hh; >     support_x1 = sin(angle) * bolt_length + cos(angle)*$d*0.5*0.40; >     support_z = cos(angle) * bolt_length - sin(angle)*$d*0.4; >     z_shift = (angle<=90) ? $z_fudge+sin(angle)*$hs*0.5 : > $z_fudge+max(sin(angle)*$hs*0.5, sin(angle)*$hs*0.5-cos(angle*$hh), > -cos(angle)*bolt_length+sin(angle)*$d*0.4); >     matrix_from_projection = frame_map(x=RIGHT, y=UP); >     matrix_to_projection = matrix_inverse(matrix_from_projection); >     union() { >         // support for the bolt >         multmatrix(matrix_from_projection) linear_extrude(height = > $support_thickness, center=true) >         difference() { >             polygon([[support_x0,0], [support_x1,0], > [support_x1,support_z+z_shift], [support_x0,z_shift]]); >             offset(r=$support_gap) projection(cut=true) > multmatrix(matrix_to_projection) printable_bolt(angle, z_shift); >             } >         // mouse ears for the support > for(x=[$support_ears_d*0.5,support_x1-$support_ears_d*0.5+0.25]) > right(x) zcyl(h=$support_ears_z, d=$support_ears_d, anchor=BOT); >         // the bolt >         printable_bolt(angle, z_shift); >         } > } > > module nut() { >     difference() { >         zcyl(h=$nh, d=$nd, chamfer=$nh*0.075, $fn=6, circum=true, > anchor=BOTTOM); >         down (eps) screw_hole($nut_spec, thread=true, > counterbore=false, bevel=true, anchor=BOTTOM); // , l=$nh+2*eps >     } > } > > // use trimscale=0.0 in setenv_bolt() for untrimmed thread > module inspect_bolt() { >     linear_extrude(height = 1) >     projection(cut=true) xrot(-90) { >         printable_bolt(); >         up($hh + $l - $nh) nut(); >         } > } > > // EXAMPLES > /* > setenv_bolt("M5,6", "hex", trimscale=0.9) >     print_bolt(); > > setenv_bolt("M4x0.8,8", head="button", drive="hex", ulength=0, > trimscale=1.05, z_fudge=-0.75, x0_fudge=0.5) >     print_bolt(angle=53.4); > > setenv_bolt("M5,6", "hex", trimscale=0.9) >     nut(); > //  inspect_bolt(); > //  printable_bolt(); > */ > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG antivirus software. www.avg.com
TA
Todd Allen
Sat, Aug 10, 2024 4:50 PM

"Interesting idea.  I assume that the dingus under the bolt is custom
support.  It seems very far away from the part: does it work?"

The example bolts are small M4 and M5.  The gap in those example is
actually only 0.15 mm.  It is adjustable like the settings used in slicers
to control the interface between supports and a part.  As set for those
examples it works on my printer, a Creality K1, to create a support that
does not separate while printing but removes in about 2 seconds leaving
minimal indication it was ever there.

On Sat, Aug 10, 2024 at 11:37 AM Jon Bondy jon@jonbondy.com wrote:

Interesting idea.  I assume that the dingus under the bolt is custom
support.  It seems very far away from the part: does it work?

Jon

On 8/9/2024 10:35 PM, Todd Allen via Discuss wrote:

It is easiest to print bolts vertically standing on their heads but
tensile strength is then maximally impacted by layer adhesion.
Printing at a significant angle from vertical can achieve much better
tensile strength but requires support or cutting the bolt to create a
flat surface to lay on the print bed to print horizontally.  There are
many cases where cutting the bolt is not a good option and for those
cases I've found it fussy to generate support in a slicer that
contacts the bolt precisely as I want to allow for clean easy support
removal.

Here's an OpenSCAD script for creating bolts to be printed at an angle
with integrated support that I've found helpful for rapidly knocking
out a variety of fasteners with good tensile strength that take
trivial clean up effort to be ready for use.  It uses
BOSL2/screws.scad to create bolts.  It's quite basic with little
polish and can require tweaking of a few parameters to get best
results but still I've found it very useful and think others might
too.  The technique I used to generate the support could readily be
adapted to a wide range of other objects.

If anyone knows of better approaches to printing bolts or generating
support I would love to hear about it.

include <BOSL2/std.scad>
include <BOSL2/screws.scad>

$fn= $preview ? 12 : 256;
eps = 0.001;

// set trimscale sufficiently large to shave enough of the threads to
eliminate or minimize producing isolated blobs when sliced that don't
print well
// set ulength=0 for no chamfer to threaded shaft
// use x0_fudge to adjust where print_bolt() support starts on x axis
// use z_fudge to adjust z height of print_bolt()
module setenv_bolt(name, head="hex", drive="none",
ulength=undef, nut_threads=2.5, nut_diameter=0,
tolerance="6g", trimscale=1.0, slop=0.06,
zrot, x0_fudge=0, z_fudge=0,
support_thickness, support_gap = 0.15, support_ears_d,
support_ears_z = 0.2)
{
spec = screw_info(name);
$name = name;
$head = head;
$drive = drive;
$p = struct_val(spec, "pitch");
$l = struct_val(spec, "length");
$d = struct_val(spec, "diameter");
$nh = $pnut_threads+1.5;
$nd = nut_diameter ? nut_diameter : $d
1.2+4.0;

 $nut_spec = struct_set(spec, [
     "length", $nh+2*eps,
     "thread_len", $nh+2*eps
     ]);

 $tolerance = tolerance;
 $trimscale = trimscale;
 $ul = is_undef(ulength) ? $p*0.5 : ulength; // should also add in

amount tolerance spec undersizes threaded minor radius
$tl = $l - $ul;
$bolt_spec = struct_set(screw_info(name, head=head, drive=drive), [
"thread_len", $tl
]);
echo($bolt_spec = $bolt_spec);

 $hs = struct_val($bolt_spec, "head_size", $d);
 $hh = struct_val($bolt_spec, "head_height", 0);

 $slop = slop;   // $slop is parameter of BOSL2 screw_hole()

 // align hex head to rest on a flat when rotated about Y axis for

printing as headsize is across flats
// may want default angles for drive types too
auto_zrot = ($head=="hex") ? 90 : 60;
$bolt_zrot = is_undef(zrot) ? auto_zrot : zrot;

 $x0_fudge = x0_fudge;
 $z_fudge = z_fudge;
 $support_thickness = is_undef(support_thickness) ? 0.9+0.1*$d:

support_thickness;
$support_gap = support_gap;
$support_ears_d = is_undef(support_ears_d) ? 3+$d : support_ears_d;
$support_ears_z = support_ears_z;

 children();

}

module bolt() {
zrot($bolt_zrot) screw(spec=$bolt_spec, tolerance=$tolerance,
orient=DOWN, anchor=TOP);
}

module shank_chamfer_mask(od, c) {
difference() {
zcyl(h=c, d=od+10eps, anchor=TOP);
up(eps) zcyl(h=c+2
eps, d=od-2*c, chamfer1=-c, anchor=TOP);
}
}

// bolt tweaked for printing with threads trimmed and end of
unthreaded shank chamfered
module printable_bolt(angle=0, z_shift=0) {
up(z_shift) yrot(angle) intersection() {
if ($ul>0) difference() {
bolt();
up($hh+$l-$tl+eps) shank_chamfer_mask($d, $p0.5);
}
else bolt();
union() {
// head
zcyl(l=$hh+$l-$tl, d=$hs+3, anchor=BOT);
// trimmed shaft
up($hh+$l-$tl-eps)
cuboid([$d-$p
$trimscale,$d,$tl+eps],anchor=BOT);
}
}
}

module print_bolt(angle=60) {
bolt_length = $hh + $l;
support_x0 = $x0_fudge + cos(angle) * $hh;
support_x1 = sin(angle) * bolt_length + cos(angle)$d0.50.40;
support_z = cos(angle) * bolt_length - sin(angle)
$d0.4;
z_shift = (angle<=90) ? $z_fudge+sin(angle)
$hs0.5 :
$z_fudge+max(sin(angle)
$hs0.5, sin(angle)$hs0.5-cos(angle$hh),
-cos(angle)bolt_length+sin(angle)$d0.4);
matrix_from_projection = frame_map(x=RIGHT, y=UP);
matrix_to_projection = matrix_inverse(matrix_from_projection);
union() {
// support for the bolt
multmatrix(matrix_from_projection) linear_extrude(height =
$support_thickness, center=true)
difference() {
polygon([[support_x0,0], [support_x1,0],
[support_x1,support_z+z_shift], [support_x0,z_shift]]);
offset(r=$support_gap) projection(cut=true)
multmatrix(matrix_to_projection) printable_bolt(angle, z_shift);
}
// mouse ears for the support
for(x=[$support_ears_d
0.5,support_x1-$support_ears_d*0.5+0.25])
right(x) zcyl(h=$support_ears_z, d=$support_ears_d, anchor=BOT);
// the bolt
printable_bolt(angle, z_shift);
}
}

module nut() {
difference() {
zcyl(h=$nh, d=$nd, chamfer=$nh0.075, $fn=6, circum=true,
anchor=BOTTOM);
down (eps) screw_hole($nut_spec, thread=true,
counterbore=false, bevel=true, anchor=BOTTOM); // , l=$nh+2
eps
}
}

// use trimscale=0.0 in setenv_bolt() for untrimmed thread
module inspect_bolt() {
linear_extrude(height = 1)
projection(cut=true) xrot(-90) {
printable_bolt();
up($hh + $l - $nh) nut();
}
}

// EXAMPLES
/*
setenv_bolt("M5,6", "hex", trimscale=0.9)
print_bolt();

setenv_bolt("M4x0.8,8", head="button", drive="hex", ulength=0,
trimscale=1.05, z_fudge=-0.75, x0_fudge=0.5)
print_bolt(angle=53.4);

setenv_bolt("M5,6", "hex", trimscale=0.9)
nut();
//  inspect_bolt();
//  printable_bolt();
*/


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

"Interesting idea. I assume that the dingus under the bolt is custom support. It seems very far away from the part: does it work?" The example bolts are small M4 and M5. The gap in those example is actually only 0.15 mm. It is adjustable like the settings used in slicers to control the interface between supports and a part. As set for those examples it works on my printer, a Creality K1, to create a support that does not separate while printing but removes in about 2 seconds leaving minimal indication it was ever there. On Sat, Aug 10, 2024 at 11:37 AM Jon Bondy <jon@jonbondy.com> wrote: > Interesting idea. I assume that the dingus under the bolt is custom > support. It seems very far away from the part: does it work? > > Jon > > On 8/9/2024 10:35 PM, Todd Allen via Discuss wrote: > > It is easiest to print bolts vertically standing on their heads but > > tensile strength is then maximally impacted by layer adhesion. > > Printing at a significant angle from vertical can achieve much better > > tensile strength but requires support or cutting the bolt to create a > > flat surface to lay on the print bed to print horizontally. There are > > many cases where cutting the bolt is not a good option and for those > > cases I've found it fussy to generate support in a slicer that > > contacts the bolt precisely as I want to allow for clean easy support > > removal. > > > > Here's an OpenSCAD script for creating bolts to be printed at an angle > > with integrated support that I've found helpful for rapidly knocking > > out a variety of fasteners with good tensile strength that take > > trivial clean up effort to be ready for use. It uses > > BOSL2/screws.scad to create bolts. It's quite basic with little > > polish and can require tweaking of a few parameters to get best > > results but still I've found it very useful and think others might > > too. The technique I used to generate the support could readily be > > adapted to a wide range of other objects. > > > > If anyone knows of better approaches to printing bolts or generating > > support I would love to hear about it. > > > > include <BOSL2/std.scad> > > include <BOSL2/screws.scad> > > > > $fn= $preview ? 12 : 256; > > eps = 0.001; > > > > // set trimscale sufficiently large to shave enough of the threads to > > eliminate or minimize producing isolated blobs when sliced that don't > > print well > > // set ulength=0 for no chamfer to threaded shaft > > // use x0_fudge to adjust where print_bolt() support starts on x axis > > // use z_fudge to adjust z height of print_bolt() > > module setenv_bolt(name, head="hex", drive="none", > > ulength=undef, nut_threads=2.5, nut_diameter=0, > > tolerance="6g", trimscale=1.0, slop=0.06, > > zrot, x0_fudge=0, z_fudge=0, > > support_thickness, support_gap = 0.15, support_ears_d, > > support_ears_z = 0.2) > > { > > spec = screw_info(name); > > $name = name; > > $head = head; > > $drive = drive; > > $p = struct_val(spec, "pitch"); > > $l = struct_val(spec, "length"); > > $d = struct_val(spec, "diameter"); > > $nh = $p*nut_threads+1.5; > > $nd = nut_diameter ? nut_diameter : $d*1.2+4.0; > > > > $nut_spec = struct_set(spec, [ > > "length", $nh+2*eps, > > "thread_len", $nh+2*eps > > ]); > > > > $tolerance = tolerance; > > $trimscale = trimscale; > > $ul = is_undef(ulength) ? $p*0.5 : ulength; // should also add in > > amount tolerance spec undersizes threaded minor radius > > $tl = $l - $ul; > > $bolt_spec = struct_set(screw_info(name, head=head, drive=drive), [ > > "thread_len", $tl > > ]); > > echo($bolt_spec = $bolt_spec); > > > > $hs = struct_val($bolt_spec, "head_size", $d); > > $hh = struct_val($bolt_spec, "head_height", 0); > > > > $slop = slop; // $slop is parameter of BOSL2 screw_hole() > > > > // align hex head to rest on a flat when rotated about Y axis for > > printing as headsize is across flats > > // may want default angles for drive types too > > auto_zrot = ($head=="hex") ? 90 : 60; > > $bolt_zrot = is_undef(zrot) ? auto_zrot : zrot; > > > > $x0_fudge = x0_fudge; > > $z_fudge = z_fudge; > > $support_thickness = is_undef(support_thickness) ? 0.9+0.1*$d: > > support_thickness; > > $support_gap = support_gap; > > $support_ears_d = is_undef(support_ears_d) ? 3+$d : support_ears_d; > > $support_ears_z = support_ears_z; > > > > children(); > > } > > > > module bolt() { > > zrot($bolt_zrot) screw(spec=$bolt_spec, tolerance=$tolerance, > > orient=DOWN, anchor=TOP); > > } > > > > module shank_chamfer_mask(od, c) { > > difference() { > > zcyl(h=c, d=od+10*eps, anchor=TOP); > > up(eps) zcyl(h=c+2*eps, d=od-2*c, chamfer1=-c, anchor=TOP); > > } > > } > > > > // bolt tweaked for printing with threads trimmed and end of > > unthreaded shank chamfered > > module printable_bolt(angle=0, z_shift=0) { > > up(z_shift) yrot(angle) intersection() { > > if ($ul>0) difference() { > > bolt(); > > up($hh+$l-$tl+eps) shank_chamfer_mask($d, $p*0.5); > > } > > else bolt(); > > union() { > > // head > > zcyl(l=$hh+$l-$tl, d=$hs+3, anchor=BOT); > > // trimmed shaft > > up($hh+$l-$tl-eps) > > cuboid([$d-$p*$trimscale,$d,$tl+eps],anchor=BOT); > > } > > } > > } > > > > module print_bolt(angle=60) { > > bolt_length = $hh + $l; > > support_x0 = $x0_fudge + cos(angle) * $hh; > > support_x1 = sin(angle) * bolt_length + cos(angle)*$d*0.5*0.40; > > support_z = cos(angle) * bolt_length - sin(angle)*$d*0.4; > > z_shift = (angle<=90) ? $z_fudge+sin(angle)*$hs*0.5 : > > $z_fudge+max(sin(angle)*$hs*0.5, sin(angle)*$hs*0.5-cos(angle*$hh), > > -cos(angle)*bolt_length+sin(angle)*$d*0.4); > > matrix_from_projection = frame_map(x=RIGHT, y=UP); > > matrix_to_projection = matrix_inverse(matrix_from_projection); > > union() { > > // support for the bolt > > multmatrix(matrix_from_projection) linear_extrude(height = > > $support_thickness, center=true) > > difference() { > > polygon([[support_x0,0], [support_x1,0], > > [support_x1,support_z+z_shift], [support_x0,z_shift]]); > > offset(r=$support_gap) projection(cut=true) > > multmatrix(matrix_to_projection) printable_bolt(angle, z_shift); > > } > > // mouse ears for the support > > for(x=[$support_ears_d*0.5,support_x1-$support_ears_d*0.5+0.25]) > > right(x) zcyl(h=$support_ears_z, d=$support_ears_d, anchor=BOT); > > // the bolt > > printable_bolt(angle, z_shift); > > } > > } > > > > module nut() { > > difference() { > > zcyl(h=$nh, d=$nd, chamfer=$nh*0.075, $fn=6, circum=true, > > anchor=BOTTOM); > > down (eps) screw_hole($nut_spec, thread=true, > > counterbore=false, bevel=true, anchor=BOTTOM); // , l=$nh+2*eps > > } > > } > > > > // use trimscale=0.0 in setenv_bolt() for untrimmed thread > > module inspect_bolt() { > > linear_extrude(height = 1) > > projection(cut=true) xrot(-90) { > > printable_bolt(); > > up($hh + $l - $nh) nut(); > > } > > } > > > > // EXAMPLES > > /* > > setenv_bolt("M5,6", "hex", trimscale=0.9) > > print_bolt(); > > > > setenv_bolt("M4x0.8,8", head="button", drive="hex", ulength=0, > > trimscale=1.05, z_fudge=-0.75, x0_fudge=0.5) > > print_bolt(angle=53.4); > > > > setenv_bolt("M5,6", "hex", trimscale=0.9) > > nut(); > > // inspect_bolt(); > > // printable_bolt(); > > */ > > > > _______________________________________________ > > OpenSCAD mailing list > > To unsubscribe send an email to discuss-leave@lists.openscad.org > > -- > This email has been checked for viruses by AVG antivirus software. > www.avg.com >
GH
gene heskett
Sat, Aug 10, 2024 4:56 PM

On 8/10/24 12:16, Glenn Butcher via Discuss wrote:

Thanks for saying it...

The few places I need threading in the models I'm printing, I tap the hole.

I bought the thread kit for the Sherline lathe, but now I wish I'd have
bought the dividing stuff to make gears.  I will cut threads on some
custom screws I need to make for locomotive valve gear, but I'll do that
with a die.

And my cnc'd Sheldon 11x54 can do all that with various G76 recipes.
Including tapered holes at some tpi or tpmm I've invented. The X
coupling was made out of the manual crank shaft by making a new one out
of A2, making a socket for the 8mm ball screw, and a tapered 50 tpi
thread on the OD, edm slit the end so it just fit the screw, made a 3/8"
nut to fit that with the same taper, inserted the screw into the socket
thus formed, and the nut ran down to compress the socket onto the screw.
annointed it with green locktite. 10 years ago using a 7x14 I'd also
cnc'd. Hasn't slipped in 10 years now. Roller thrust washers, backlash
is around 1.2 thou a decade later. As an ex BIL used to say, good enough
for the girls I go with. ;o)>

Reminds me, need to ping MicroMark on my 0-90 die backorder...

On 8/10/2024 8:50 AM, Marcus Poller via Discuss wrote:

Todd Allen via Discuss wrote:

It is easiest to print bolts vertically standing on their heads but
tensile
strength is then maximally impacted by layer adhesion.

After printing many bolts I have come to the conclusion that I safe
more time buying them than printing them.
Those are standard components, you can have them in any head-shape,
thread-size, and color.
If I print a bolt

  * I have to use a thread cutting tool to free the print object of
slicer artifacts and oozing
  * I am at risk that the bolt layers will separate in operation (it
breaks or peals apart)
  * it takes a lot more time than reaching for my toolbox of bolts

I have personally settled to own a collection of many differnt lengths
of M3-bolts [1], soldering in thread [2], default and safety (plastic
ring inlay) nuts [3] and screw glue [4].

It is way easier than printing 10 bolts and then figuring out while 3
of them cannot be fastened with a nut.

My OpenSCAD-preview contains bolts. I need to be sure bolts do not
overlap and I can access their head with a tool for fasting. But I
have come to the personal conclusion that I should stop printing bolts.

Agreed, Monsterbolts has about anything you might want. I just got a bag
of 50, 5mmx30mm ti SHCS for idler axles on a 400mm sq tronxy printer, ti
is a bit lighter than steel and some are flying weight. Beautifully made
bolts. Downright purty even.

Cheers, Gene Heskett, CET.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

  • Louis D. Brandeis
On 8/10/24 12:16, Glenn Butcher via Discuss wrote: > Thanks for saying it... > > The few places I need threading in the models I'm printing, I tap the hole. > > I bought the thread kit for the Sherline lathe, but now I wish I'd have > bought the dividing stuff to make gears.  I will cut threads on some > custom screws I need to make for locomotive valve gear, but I'll do that > with a die. And my cnc'd Sheldon 11x54 can do all that with various G76 recipes. Including tapered holes at some tpi or tpmm I've invented. The X coupling was made out of the manual crank shaft by making a new one out of A2, making a socket for the 8mm ball screw, and a tapered 50 tpi thread on the OD, edm slit the end so it just fit the screw, made a 3/8" nut to fit that with the same taper, inserted the screw into the socket thus formed, and the nut ran down to compress the socket onto the screw. annointed it with green locktite. 10 years ago using a 7x14 I'd also cnc'd. Hasn't slipped in 10 years now. Roller thrust washers, backlash is around 1.2 thou a decade later. As an ex BIL used to say, good enough for the girls I go with. ;o)> > > Reminds me, need to ping MicroMark on my 0-90 die backorder... > > On 8/10/2024 8:50 AM, Marcus Poller via Discuss wrote: >> Todd Allen via Discuss wrote: >>> It is easiest to print bolts vertically standing on their heads but >>> tensile >>> strength is then maximally impacted by layer adhesion. >> >> After printing many bolts I have come to the conclusion that I safe >> more time buying them than printing them. >> Those are standard components, you can have them in any head-shape, >> thread-size, and color. >> If I print a bolt >> >>   * I have to use a thread cutting tool to free the print object of >> slicer artifacts and oozing >>   * I am at risk that the bolt layers will separate in operation (it >> breaks or peals apart) >>   * it takes a lot more time than reaching for my toolbox of bolts >> >> I have personally settled to own a collection of many differnt lengths >> of M3-bolts [1], soldering in thread [2], default and safety (plastic >> ring inlay) nuts [3] and screw glue [4]. >> >> It is way easier than printing 10 bolts and then figuring out while 3 >> of them cannot be fastened with a nut. >> >> My OpenSCAD-preview contains bolts. I need to be sure bolts do not >> overlap and I can access their head with a tool for fasting. But I >> have come to the personal conclusion that I should stop printing bolts. Agreed, Monsterbolts has about anything you might want. I just got a bag of 50, 5mmx30mm ti SHCS for idler axles on a 400mm sq tronxy printer, ti is a bit lighter than steel and some are flying weight. Beautifully made bolts. Downright purty even. >> Just my two cents, >> Marcus >> >> [1] >> https://www.hornbach.de/p/linsenkopfschraube-m-kreuzschlitz-din-7985-m3x12-mm-edelstahl-a2-100-stueck/6836149/ >> I even own m3x45 for 3d printed toys with long axles >> [2] >> https://www.amazon.de/ruthex-Gewindeeinsatz-St%C3%BCck-Gewindebuchsen-Kunststoffteile/dp/B08BCRZZS3?ref_=ast_sto_dp&th=1 >> [3] >> https://www.hornbach.de/p/sechskant-sicherungsmutter-selbstsichernd-reyher-din-985-m3-galv-verzinkt-100-stueck/10316758/ >> [4] >> https://www.hornbach.de/p/loctite-schraubensicherung-243-mittelfest-normal-5-ml/7663487/ >> Anything that has to sustain vibrations, like childrens toys, needs to >> be either secured or glued. >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org Cheers, Gene Heskett, CET. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis
TA
Todd Allen
Sat, Aug 10, 2024 8:42 PM

"The use cases for printing threads are when you want something unusual and
strength requirements are modest.  I printed a mount to hold a phone for
example that had a threaded shaft to clamp the phone in place.  It worked
well."

My use cases are expanding as I find it easier to produce fasteners of
better quality.  Here's an example though of something unusual with minimal
need of physical strength but high need for weather resistance, a print in
ASA to mount a solar panel on a fence to power a bird bath pump.  The mount
clamps to the panel with a couple bolts about 120 mm long and uses smaller
bolts for easily adjustable tilt.  I could have designed it differently
without using bolts but it would have required more time and effort.  This
was a simple design that was easy to conceptualize, fast to script and fast
to print and assemble with all parts working on the first print which was
made possible by knowing I would easily print those fasteners without
tolerance issues.  I could have saved a little plastic by printing smaller
diameter fasteners but I had a 0.6 mm nozzle mounted and I chose to save
the time of swapping nozzles.

And I like the look of entirely printed solutions.  Stainless hardware
would have been overkill for this while zinc plated might corrode and seize
up long before the plastic degrades.
[image: solar panel mount_800.jpg]

On Sat, Aug 10, 2024 at 10:38 AM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

Sorry about overlooking your reference to flat sided bolts.

I agree with Marcus that when standard hardware exists---use it.  It's
strong and ultimately easier to grab from a box than printing a fussy
model.  The use cases for printing threads are when you want something
unusual and strength requirements are modest.  I printed a mount to hold a
phone for example that had a threaded shaft to clamp the phone in place.
It worked well.  The screw was big, and very fast---probably not something
you could buy.  You don't need tremendous strength for this application.
Note that this device also mounted to a tripod mount and accomplished this
by means of added metal hardware, not printed threads.  Another use case
for printed threads is if you want to make a circular box with a screw-top
lid, or print lids for glass or plastic jars.  These threads are fairly big
and the strength requirements are generally low.

Printing lets you do things that are unsual. I read about "diamond"
threads where you superimpose left handed and right handed threads on a
single bolt.  Then left handed and right handed nuts can both travel on the
bolt.  I don't know if it's good for anything, but it's an interesting
thing to fiddle with and as such, doesn't need to be strong---works fine
printed vertically.  See Example 7 here:
https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#module-threaded_rod

I think there's a better case for printing threaded holes.  There is no
narrow shaft to shear in half.  I think threaded holes can work OK even at
fairly small sizes.  If I recall correctly I tested sizes down to #6, which
is 3.5mm.  (My hardware is almost all imperial rather than metric.)  I have
done a bunch of printing of 1/4-20 (~6mm) size threads and they seem fine.
Another option is to print a hole and add threads with a tap.  And then
there's the approach Gene suggests of basically letting the screw be its
own tap.  The BOSL2 screw_hole() module supports all of these options  The
"tap" tolerance makes a hole the right size for tapping.  The "self tap"
tolerance makes an undersized hole sized for self-tapping with a screw.  I
tested it between #2 (2mm) and 1/2 inch (13mm).

But if you're trying to hang an elephant on the screw you should use a nut
trap.

On Sat, Aug 10, 2024 at 10:54 AM Todd Allen via Discuss <
discuss@lists.openscad.org> wrote:

"I normally put the bolthole at whatever angle is needed, using the
cylinder primative, with $fn at 5 to 7, and sized so the result is self
threading at 60% to 70% engagement. In PETG, the bolr will be self
threading and have plenty of self locking to never jiggle out."

That's exactly the sort of discussion I was hoping for.  To hear new
things I probably would have never thought to try.  The reason I used
BOSL2/screws.scad instead of the more flexible BOSL2/threading.scad in the
script I posted is the ease of producing fasteners with stock threads
compatible with taps and dies specifically for the case of printing bolt
holes horizontally where the threads at the top are poorly formed and need
to be chased with a tap.  But I expect your solution can handle many
situations and save the extra time and fuss of the way I've done it.

"Most of the bolts I use are in the 2.5 to 5mm range, threads too fine to
ever
consider printing them."

I used to think that too when I only printed fasteners vertically or
horizontally.  Horizontally one is limited to about 6 mm by the crappiness
of the threads formed and vertically one hits about the same limit not by
the threads but by the minor diameter and the difficulty of printing it
with adequate precision and strength as precision requires smaller
extrusion width and greater cooling while strength requires the opposite.
But when printing at angles of 50 to 70 degrees from vertical I find it
much easier to get good results at smaller sizes which is why I did
examples at 4 and 5 mm.

On Sat, Aug 10, 2024 at 2:25 AM gene heskett via Discuss <
discuss@lists.openscad.org> wrote:

On 8/9/24 22:35, Todd Allen via Discuss wrote:

It is easiest to print bolts vertically standing on their heads but
tensile strength is then maximally impacted by layer adhesion.

Printing

at a significant angle from vertical can achieve much better tensile
strength but requires support or cutting the bolt to create a flat
surface to lay on the print bed to print horizontally.  There are many
cases where cutting the bolt is not a good option and for those cases
I've found it fussy to generate support in a slicer that contacts the
bolt precisely as I want to allow for clean easy support removal.

Here's an OpenSCAD script for creating bolts to be printed at an angle
with integrated support that I've found helpful for rapidly knocking

out

a variety of fasteners with good tensile strength that take trivial
clean up effort to be ready for use.  It uses BOSL2/screws.scad to
create bolts.  It's quite basic with little polish and can require
tweaking of a few parameters to get best results but still I've found

it

very useful and think others might too.  The technique I used to
generate the support could readily be adapted to a wide range of other
objects.

If anyone knows of better approaches to printing bolts or generating
support I would love to hear about it.

include <BOSL2/std.scad>
include <BOSL2/screws.scad>

$fn= $preview ? 12 : 256;
eps = 0.001;

// set trimscale sufficiently large to shave enough of the threads to
eliminate or minimize producing isolated blobs when sliced that don't
print well
// set ulength=0 for no chamfer to threaded shaft
// use x0_fudge to adjust where print_bolt() support starts on x axis
// use z_fudge to adjust z height of print_bolt()
module setenv_bolt(name, head="hex", drive="none",
ulength=undef, nut_threads=2.5, nut_diameter=0,
tolerance="6g", trimscale=1.0, slop=0.06,
zrot, x0_fudge=0, z_fudge=0,
support_thickness, support_gap = 0.15, support_ears_d,
support_ears_z = 0.2)
{
spec = screw_info(name);
$name = name;
$head = head;
$drive = drive;
$p = struct_val(spec, "pitch");
$l = struct_val(spec, "length");
$d = struct_val(spec, "diameter");
$nh = $pnut_threads+1.5;
$nd = nut_diameter ? nut_diameter : $d
1.2+4.0;

  $nut_spec = struct_set(spec, [
      "length", $nh+2*eps,
      "thread_len", $nh+2*eps
      ]);

  $tolerance = tolerance;
  $trimscale = trimscale;
  $ul = is_undef(ulength) ? $p*0.5 : ulength; // should also add in

amount tolerance spec undersizes threaded minor radius
$tl = $l - $ul;
$bolt_spec = struct_set(screw_info(name, head=head, drive=drive),

[

      "thread_len", $tl
      ]);
  echo($bolt_spec = $bolt_spec);

  $hs = struct_val($bolt_spec, "head_size", $d);
  $hh = struct_val($bolt_spec, "head_height", 0);

  $slop = slop;   // $slop is parameter of BOSL2 screw_hole()

  // align hex head to rest on a flat when rotated about Y axis for

printing as headsize is across flats
// may want default angles for drive types too
auto_zrot = ($head=="hex") ? 90 : 60;
$bolt_zrot = is_undef(zrot) ? auto_zrot : zrot;

  $x0_fudge = x0_fudge;
  $z_fudge = z_fudge;
  $support_thickness = is_undef(support_thickness) ? 0.9+0.1*$d:

support_thickness;
$support_gap = support_gap;
$support_ears_d = is_undef(support_ears_d) ? 3+$d :

support_ears_d;

  $support_ears_z = support_ears_z;

  children();

}

module bolt() {
zrot($bolt_zrot) screw(spec=$bolt_spec, tolerance=$tolerance,
orient=DOWN, anchor=TOP);
}

module shank_chamfer_mask(od, c) {
difference() {
zcyl(h=c, d=od+10eps, anchor=TOP);
up(eps) zcyl(h=c+2
eps, d=od-2*c, chamfer1=-c, anchor=TOP);
}
}

// bolt tweaked for printing with threads trimmed and end of

unthreaded

shank chamfered
module printable_bolt(angle=0, z_shift=0) {
up(z_shift) yrot(angle) intersection() {
if ($ul>0) difference() {
bolt();
up($hh+$l-$tl+eps) shank_chamfer_mask($d, $p0.5);
}
else bolt();
union() {
// head
zcyl(l=$hh+$l-$tl, d=$hs+3, anchor=BOT);
// trimmed shaft
up($hh+$l-$tl-eps)
cuboid([$d-$p
$trimscale,$d,$tl+eps],anchor=BOT);
}
}
}

module print_bolt(angle=60) {
bolt_length = $hh + $l;
support_x0 = $x0_fudge + cos(angle) * $hh;
support_x1 = sin(angle) * bolt_length + cos(angle)$d0.50.40;
support_z = cos(angle) * bolt_length - sin(angle)
$d0.4;
z_shift = (angle<=90) ? $z_fudge+sin(angle)
$hs0.5 :
$z_fudge+max(sin(angle)
$hs0.5, sin(angle)$hs0.5-cos(angle$hh),
-cos(angle)bolt_length+sin(angle)$d*0.4);
matrix_from_projection = frame_map(x=RIGHT, y=UP);
matrix_to_projection = matrix_inverse(matrix_from_projection);
union() {
// support for the bolt
multmatrix(matrix_from_projection) linear_extrude(height =
$support_thickness, center=true)
difference() {
polygon([[support_x0,0], [support_x1,0],
[support_x1,support_z+z_shift], [support_x0,z_shift]]);
offset(r=$support_gap) projection(cut=true)
multmatrix(matrix_to_projection) printable_bolt(angle, z_shift);
}
// mouse ears for the support

for(x=[$support_ears_d0.5,support_x1-$support_ears_d0.5+0.25])
right(x) zcyl(h=$support_ears_z, d=$support_ears_d, anchor=BOT);
// the bolt
printable_bolt(angle, z_shift);
}
}

module nut() {
difference() {
zcyl(h=$nh, d=$nd, chamfer=$nh0.075, $fn=6, circum=true,
anchor=BOTTOM);
down (eps) screw_hole($nut_spec, thread=true,
counterbore=false, bevel=true, anchor=BOTTOM); // , l=$nh+2
eps
}
}

// use trimscale=0.0 in setenv_bolt() for untrimmed thread
module inspect_bolt() {
linear_extrude(height = 1)
projection(cut=true) xrot(-90) {
printable_bolt();
up($hh + $l - $nh) nut();
}
}

// EXAMPLES
/*
setenv_bolt("M5,6", "hex", trimscale=0.9)
print_bolt();

setenv_bolt("M4x0.8,8", head="button", drive="hex", ulength=0,
trimscale=1.05, z_fudge=-0.75, x0_fudge=0.5)
print_bolt(angle=53.4);

setenv_bolt("M5,6", "hex", trimscale=0.9)
nut();
//  inspect_bolt();
//  printable_bolt();
*/

This s/b just the ticket for bigger bolts, say 12mm and up.

I normally put the bolthole at whatever angle is needed, using the
cylinder primative, with $fn at 5 to 7, and sized so the result is self
threading at 60% to 70% engagement. In PETG, the bolr will be self
threading and have plenty of self locking to never jiggle out. Much
simpler to mount a fan at the right angle for max cooling or ??.  Most
of the bolts I use are in the 2.5 to 5mm range, threads too fine to ever
consider printing them. Use PETG's flexibility to advantage. Probably
not a good idea in pla, too brittle. Works even in PC for me. PC needs
bed temps in 120+ range and nozzles close to 300C though, temps well
beyond consuner printers.  Like the gpl, if it breaks, I get to keep all
the pieces. ;o)> And then make a stronger part in OpenSCAD.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Cheers, Gene Heskett, CET.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

  • Louis D. Brandeis

OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

"The use cases for printing threads are when you want something unusual and strength requirements are modest. I printed a mount to hold a phone for example that had a threaded shaft to clamp the phone in place. It worked well." My use cases are expanding as I find it easier to produce fasteners of better quality. Here's an example though of something unusual with minimal need of physical strength but high need for weather resistance, a print in ASA to mount a solar panel on a fence to power a bird bath pump. The mount clamps to the panel with a couple bolts about 120 mm long and uses smaller bolts for easily adjustable tilt. I could have designed it differently without using bolts but it would have required more time and effort. This was a simple design that was easy to conceptualize, fast to script and fast to print and assemble with all parts working on the first print which was made possible by knowing I would easily print those fasteners without tolerance issues. I could have saved a little plastic by printing smaller diameter fasteners but I had a 0.6 mm nozzle mounted and I chose to save the time of swapping nozzles. And I like the look of entirely printed solutions. Stainless hardware would have been overkill for this while zinc plated might corrode and seize up long before the plastic degrades. [image: solar panel mount_800.jpg] On Sat, Aug 10, 2024 at 10:38 AM Adrian Mariano via Discuss < discuss@lists.openscad.org> wrote: > Sorry about overlooking your reference to flat sided bolts. > > I agree with Marcus that when standard hardware exists---use it. It's > strong and ultimately easier to grab from a box than printing a fussy > model. The use cases for printing threads are when you want something > unusual and strength requirements are modest. I printed a mount to hold a > phone for example that had a threaded shaft to clamp the phone in place. > It worked well. The screw was big, and very fast---probably not something > you could buy. You don't need tremendous strength for this application. > Note that this device also mounted to a tripod mount and accomplished this > by means of added metal hardware, not printed threads. Another use case > for printed threads is if you want to make a circular box with a screw-top > lid, or print lids for glass or plastic jars. These threads are fairly big > and the strength requirements are generally low. > > Printing lets you do things that are unsual. I read about "diamond" > threads where you superimpose left handed and right handed threads on a > single bolt. Then left handed and right handed nuts can both travel on the > bolt. I don't know if it's good for anything, but it's an interesting > thing to fiddle with and as such, doesn't need to be strong---works fine > printed vertically. See Example 7 here: > https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#module-threaded_rod > > I think there's a better case for printing threaded holes. There is no > narrow shaft to shear in half. I think threaded holes can work OK even at > fairly small sizes. If I recall correctly I tested sizes down to #6, which > is 3.5mm. (My hardware is almost all imperial rather than metric.) I have > done a bunch of printing of 1/4-20 (~6mm) size threads and they seem fine. > Another option is to print a hole and add threads with a tap. And then > there's the approach Gene suggests of basically letting the screw be its > own tap. The BOSL2 screw_hole() module supports all of these options The > "tap" tolerance makes a hole the right size for tapping. The "self tap" > tolerance makes an undersized hole sized for self-tapping with a screw. I > tested it between #2 (2mm) and 1/2 inch (13mm). > > But if you're trying to hang an elephant on the screw you should use a nut > trap. > > On Sat, Aug 10, 2024 at 10:54 AM Todd Allen via Discuss < > discuss@lists.openscad.org> wrote: > >> "I normally put the bolthole at whatever angle is needed, using the >> cylinder primative, with $fn at 5 to 7, and sized so the result is self >> threading at 60% to 70% engagement. In PETG, the bolr will be self >> threading and have plenty of self locking to never jiggle out." >> >> That's exactly the sort of discussion I was hoping for. To hear new >> things I probably would have never thought to try. The reason I used >> BOSL2/screws.scad instead of the more flexible BOSL2/threading.scad in the >> script I posted is the ease of producing fasteners with stock threads >> compatible with taps and dies specifically for the case of printing bolt >> holes horizontally where the threads at the top are poorly formed and need >> to be chased with a tap. But I expect your solution can handle many >> situations and save the extra time and fuss of the way I've done it. >> >> "Most of the bolts I use are in the 2.5 to 5mm range, threads too fine to >> ever >> consider printing them." >> >> I used to think that too when I only printed fasteners vertically or >> horizontally. Horizontally one is limited to about 6 mm by the crappiness >> of the threads formed and vertically one hits about the same limit not by >> the threads but by the minor diameter and the difficulty of printing it >> with adequate precision and strength as precision requires smaller >> extrusion width and greater cooling while strength requires the opposite. >> But when printing at angles of 50 to 70 degrees from vertical I find it >> much easier to get good results at smaller sizes which is why I did >> examples at 4 and 5 mm. >> >> On Sat, Aug 10, 2024 at 2:25 AM gene heskett via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> On 8/9/24 22:35, Todd Allen via Discuss wrote: >>> > It is easiest to print bolts vertically standing on their heads but >>> > tensile strength is then maximally impacted by layer adhesion. >>> Printing >>> > at a significant angle from vertical can achieve much better tensile >>> > strength but requires support or cutting the bolt to create a flat >>> > surface to lay on the print bed to print horizontally. There are many >>> > cases where cutting the bolt is not a good option and for those cases >>> > I've found it fussy to generate support in a slicer that contacts the >>> > bolt precisely as I want to allow for clean easy support removal. >>> > >>> > Here's an OpenSCAD script for creating bolts to be printed at an angle >>> > with integrated support that I've found helpful for rapidly knocking >>> out >>> > a variety of fasteners with good tensile strength that take trivial >>> > clean up effort to be ready for use. It uses BOSL2/screws.scad to >>> > create bolts. It's quite basic with little polish and can require >>> > tweaking of a few parameters to get best results but still I've found >>> it >>> > very useful and think others might too. The technique I used to >>> > generate the support could readily be adapted to a wide range of other >>> > objects. >>> > >>> > If anyone knows of better approaches to printing bolts or generating >>> > support I would love to hear about it. >>> > >>> > include <BOSL2/std.scad> >>> > include <BOSL2/screws.scad> >>> > >>> > $fn= $preview ? 12 : 256; >>> > eps = 0.001; >>> > >>> > // set trimscale sufficiently large to shave enough of the threads to >>> > eliminate or minimize producing isolated blobs when sliced that don't >>> > print well >>> > // set ulength=0 for no chamfer to threaded shaft >>> > // use x0_fudge to adjust where print_bolt() support starts on x axis >>> > // use z_fudge to adjust z height of print_bolt() >>> > module setenv_bolt(name, head="hex", drive="none", >>> > ulength=undef, nut_threads=2.5, nut_diameter=0, >>> > tolerance="6g", trimscale=1.0, slop=0.06, >>> > zrot, x0_fudge=0, z_fudge=0, >>> > support_thickness, support_gap = 0.15, support_ears_d, >>> > support_ears_z = 0.2) >>> > { >>> > spec = screw_info(name); >>> > $name = name; >>> > $head = head; >>> > $drive = drive; >>> > $p = struct_val(spec, "pitch"); >>> > $l = struct_val(spec, "length"); >>> > $d = struct_val(spec, "diameter"); >>> > $nh = $p*nut_threads+1.5; >>> > $nd = nut_diameter ? nut_diameter : $d*1.2+4.0; >>> > >>> > $nut_spec = struct_set(spec, [ >>> > "length", $nh+2*eps, >>> > "thread_len", $nh+2*eps >>> > ]); >>> > >>> > $tolerance = tolerance; >>> > $trimscale = trimscale; >>> > $ul = is_undef(ulength) ? $p*0.5 : ulength; // should also add in >>> > amount tolerance spec undersizes threaded minor radius >>> > $tl = $l - $ul; >>> > $bolt_spec = struct_set(screw_info(name, head=head, drive=drive), >>> [ >>> > "thread_len", $tl >>> > ]); >>> > echo($bolt_spec = $bolt_spec); >>> > >>> > $hs = struct_val($bolt_spec, "head_size", $d); >>> > $hh = struct_val($bolt_spec, "head_height", 0); >>> > >>> > $slop = slop; // $slop is parameter of BOSL2 screw_hole() >>> > >>> > // align hex head to rest on a flat when rotated about Y axis for >>> > printing as headsize is across flats >>> > // may want default angles for drive types too >>> > auto_zrot = ($head=="hex") ? 90 : 60; >>> > $bolt_zrot = is_undef(zrot) ? auto_zrot : zrot; >>> > >>> > $x0_fudge = x0_fudge; >>> > $z_fudge = z_fudge; >>> > $support_thickness = is_undef(support_thickness) ? 0.9+0.1*$d: >>> > support_thickness; >>> > $support_gap = support_gap; >>> > $support_ears_d = is_undef(support_ears_d) ? 3+$d : >>> support_ears_d; >>> > $support_ears_z = support_ears_z; >>> > >>> > children(); >>> > } >>> > >>> > module bolt() { >>> > zrot($bolt_zrot) screw(spec=$bolt_spec, tolerance=$tolerance, >>> > orient=DOWN, anchor=TOP); >>> > } >>> > >>> > module shank_chamfer_mask(od, c) { >>> > difference() { >>> > zcyl(h=c, d=od+10*eps, anchor=TOP); >>> > up(eps) zcyl(h=c+2*eps, d=od-2*c, chamfer1=-c, anchor=TOP); >>> > } >>> > } >>> > >>> > // bolt tweaked for printing with threads trimmed and end of >>> unthreaded >>> > shank chamfered >>> > module printable_bolt(angle=0, z_shift=0) { >>> > up(z_shift) yrot(angle) intersection() { >>> > if ($ul>0) difference() { >>> > bolt(); >>> > up($hh+$l-$tl+eps) shank_chamfer_mask($d, $p*0.5); >>> > } >>> > else bolt(); >>> > union() { >>> > // head >>> > zcyl(l=$hh+$l-$tl, d=$hs+3, anchor=BOT); >>> > // trimmed shaft >>> > up($hh+$l-$tl-eps) >>> > cuboid([$d-$p*$trimscale,$d,$tl+eps],anchor=BOT); >>> > } >>> > } >>> > } >>> > >>> > module print_bolt(angle=60) { >>> > bolt_length = $hh + $l; >>> > support_x0 = $x0_fudge + cos(angle) * $hh; >>> > support_x1 = sin(angle) * bolt_length + cos(angle)*$d*0.5*0.40; >>> > support_z = cos(angle) * bolt_length - sin(angle)*$d*0.4; >>> > z_shift = (angle<=90) ? $z_fudge+sin(angle)*$hs*0.5 : >>> > $z_fudge+max(sin(angle)*$hs*0.5, sin(angle)*$hs*0.5-cos(angle*$hh), >>> > -cos(angle)*bolt_length+sin(angle)*$d*0.4); >>> > matrix_from_projection = frame_map(x=RIGHT, y=UP); >>> > matrix_to_projection = matrix_inverse(matrix_from_projection); >>> > union() { >>> > // support for the bolt >>> > multmatrix(matrix_from_projection) linear_extrude(height = >>> > $support_thickness, center=true) >>> > difference() { >>> > polygon([[support_x0,0], [support_x1,0], >>> > [support_x1,support_z+z_shift], [support_x0,z_shift]]); >>> > offset(r=$support_gap) projection(cut=true) >>> > multmatrix(matrix_to_projection) printable_bolt(angle, z_shift); >>> > } >>> > // mouse ears for the support >>> > >>> > for(x=[$support_ears_d*0.5,support_x1-$support_ears_d*0.5+0.25]) >>> > right(x) zcyl(h=$support_ears_z, d=$support_ears_d, anchor=BOT); >>> > // the bolt >>> > printable_bolt(angle, z_shift); >>> > } >>> > } >>> > >>> > module nut() { >>> > difference() { >>> > zcyl(h=$nh, d=$nd, chamfer=$nh*0.075, $fn=6, circum=true, >>> > anchor=BOTTOM); >>> > down (eps) screw_hole($nut_spec, thread=true, >>> > counterbore=false, bevel=true, anchor=BOTTOM); // , l=$nh+2*eps >>> > } >>> > } >>> > >>> > // use trimscale=0.0 in setenv_bolt() for untrimmed thread >>> > module inspect_bolt() { >>> > linear_extrude(height = 1) >>> > projection(cut=true) xrot(-90) { >>> > printable_bolt(); >>> > up($hh + $l - $nh) nut(); >>> > } >>> > } >>> > >>> > // EXAMPLES >>> > /* >>> > setenv_bolt("M5,6", "hex", trimscale=0.9) >>> > print_bolt(); >>> > >>> > setenv_bolt("M4x0.8,8", head="button", drive="hex", ulength=0, >>> > trimscale=1.05, z_fudge=-0.75, x0_fudge=0.5) >>> > print_bolt(angle=53.4); >>> > >>> > setenv_bolt("M5,6", "hex", trimscale=0.9) >>> > nut(); >>> > // inspect_bolt(); >>> > // printable_bolt(); >>> > */ >>> > >>> This s/b just the ticket for bigger bolts, say 12mm and up. >>> >>> I normally put the bolthole at whatever angle is needed, using the >>> cylinder primative, with $fn at 5 to 7, and sized so the result is self >>> threading at 60% to 70% engagement. In PETG, the bolr will be self >>> threading and have plenty of self locking to never jiggle out. Much >>> simpler to mount a fan at the right angle for max cooling or ??. Most >>> of the bolts I use are in the 2.5 to 5mm range, threads too fine to ever >>> consider printing them. Use PETG's flexibility to advantage. Probably >>> not a good idea in pla, too brittle. Works even in PC for me. PC needs >>> bed temps in 120+ range and nozzles close to 300C though, temps well >>> beyond consuner printers. Like the gpl, if it breaks, I get to keep all >>> the pieces. ;o)> And then make a stronger part in OpenSCAD. >>> >>> > _______________________________________________ >>> > OpenSCAD mailing list >>> > To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> Cheers, Gene Heskett, CET. >>> -- >>> "There are four boxes to be used in defense of liberty: >>> soap, ballot, jury, and ammo. Please use in that order." >>> -Ed Howdershelt (Author, 1940) >>> If we desire respect for the law, we must first make the law respectable. >>> - Louis D. Brandeis >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
TA
Todd Allen
Fri, Dec 13, 2024 1:15 AM

[image: MiniScrews.jpg][image: DryBox.jpg][image: assembly.jpg]

On Fri, Aug 9, 2024 at 9:35 PM Todd Allen speedebikes@gmail.com wrote:

It is easiest to print bolts vertically standing on their heads but
tensile strength is then maximally impacted by layer adhesion.  Printing at
a significant angle from vertical can achieve much better tensile strength
but requires support or cutting the bolt to create a flat surface to lay on
the print bed to print horizontally.  There are many cases where cutting
the bolt is not a good option and for those cases I've found it fussy to
generate support in a slicer that contacts the bolt precisely as I want to
allow for clean easy support removal.

Here's an OpenSCAD script for creating bolts to be printed at an angle
with integrated support that I've found helpful for rapidly knocking out a
variety of fasteners with good tensile strength that take trivial clean up
effort to be ready for use.  It uses BOSL2/screws.scad to create bolts.
It's quite basic with little polish and can require tweaking of a few
parameters to get best results but still I've found it very useful and
think others might too.  The technique I used to generate the support could
readily be adapted to a wide range of other objects.

If anyone knows of better approaches to printing bolts or generating
support I would love to hear about it.

include <BOSL2/std.scad>
include <BOSL2/screws.scad>

$fn= $preview ? 12 : 256;
eps = 0.001;

// set trimscale sufficiently large to shave enough of the threads to
eliminate or minimize producing isolated blobs when sliced that don't print
well
// set ulength=0 for no chamfer to threaded shaft
// use x0_fudge to adjust where print_bolt() support starts on x axis
// use z_fudge to adjust z height of print_bolt()
module setenv_bolt(name, head="hex", drive="none",
ulength=undef, nut_threads=2.5, nut_diameter=0,
tolerance="6g", trimscale=1.0, slop=0.06,
zrot, x0_fudge=0, z_fudge=0,
support_thickness, support_gap = 0.15, support_ears_d, support_ears_z
= 0.2)
{
spec = screw_info(name);
$name = name;
$head = head;
$drive = drive;
$p = struct_val(spec, "pitch");
$l = struct_val(spec, "length");
$d = struct_val(spec, "diameter");
$nh = $pnut_threads+1.5;
$nd = nut_diameter ? nut_diameter : $d
1.2+4.0;

 $nut_spec = struct_set(spec, [
     "length", $nh+2*eps,
     "thread_len", $nh+2*eps
     ]);

 $tolerance = tolerance;
 $trimscale = trimscale;
 $ul = is_undef(ulength) ? $p*0.5 : ulength; // should also add in

amount tolerance spec undersizes threaded minor radius
$tl = $l - $ul;
$bolt_spec = struct_set(screw_info(name, head=head, drive=drive), [
"thread_len", $tl
]);
echo($bolt_spec = $bolt_spec);

 $hs = struct_val($bolt_spec, "head_size", $d);
 $hh = struct_val($bolt_spec, "head_height", 0);

 $slop = slop;   // $slop is parameter of BOSL2 screw_hole()

 // align hex head to rest on a flat when rotated about Y axis for

printing as headsize is across flats
// may want default angles for drive types too
auto_zrot = ($head=="hex") ? 90 : 60;
$bolt_zrot = is_undef(zrot) ? auto_zrot : zrot;

 $x0_fudge = x0_fudge;
 $z_fudge = z_fudge;
 $support_thickness = is_undef(support_thickness) ? 0.9+0.1*$d:

support_thickness;
$support_gap = support_gap;
$support_ears_d = is_undef(support_ears_d) ? 3+$d : support_ears_d;
$support_ears_z = support_ears_z;

 children();

}

module bolt() {
zrot($bolt_zrot) screw(spec=$bolt_spec, tolerance=$tolerance,
orient=DOWN, anchor=TOP);
}

module shank_chamfer_mask(od, c) {
difference() {
zcyl(h=c, d=od+10eps, anchor=TOP);
up(eps) zcyl(h=c+2
eps, d=od-2*c, chamfer1=-c, anchor=TOP);
}
}

// bolt tweaked for printing with threads trimmed and end of unthreaded
shank chamfered
module printable_bolt(angle=0, z_shift=0) {
up(z_shift) yrot(angle) intersection() {
if ($ul>0) difference() {
bolt();
up($hh+$l-$tl+eps) shank_chamfer_mask($d, $p0.5);
}
else bolt();
union() {
// head
zcyl(l=$hh+$l-$tl, d=$hs+3, anchor=BOT);
// trimmed shaft
up($hh+$l-$tl-eps)
cuboid([$d-$p
$trimscale,$d,$tl+eps],anchor=BOT);
}
}
}

module print_bolt(angle=60) {
bolt_length = $hh + $l;
support_x0 = $x0_fudge + cos(angle) * $hh;
support_x1 = sin(angle) * bolt_length + cos(angle)$d0.50.40;
support_z = cos(angle) * bolt_length - sin(angle)
$d0.4;
z_shift = (angle<=90) ? $z_fudge+sin(angle)
$hs0.5 :
$z_fudge+max(sin(angle)
$hs0.5, sin(angle)$hs0.5-cos(angle$hh),
-cos(angle)bolt_length+sin(angle)$d0.4);
matrix_from_projection = frame_map(x=RIGHT, y=UP);
matrix_to_projection = matrix_inverse(matrix_from_projection);
union() {
// support for the bolt
multmatrix(matrix_from_projection) linear_extrude(height =
$support_thickness, center=true)
difference() {
polygon([[support_x0,0], [support_x1,0],
[support_x1,support_z+z_shift], [support_x0,z_shift]]);
offset(r=$support_gap) projection(cut=true)
multmatrix(matrix_to_projection) printable_bolt(angle, z_shift);
}
// mouse ears for the support
for(x=[$support_ears_d
0.5,support_x1-$support_ears_d*0.5+0.25])
right(x) zcyl(h=$support_ears_z, d=$support_ears_d, anchor=BOT);
// the bolt
printable_bolt(angle, z_shift);
}
}

module nut() {
difference() {
zcyl(h=$nh, d=$nd, chamfer=$nh0.075, $fn=6, circum=true,
anchor=BOTTOM);
down (eps) screw_hole($nut_spec, thread=true, counterbore=false,
bevel=true, anchor=BOTTOM); // , l=$nh+2
eps
}
}

// use trimscale=0.0 in setenv_bolt() for untrimmed thread
module inspect_bolt() {
linear_extrude(height = 1)
projection(cut=true) xrot(-90) {
printable_bolt();
up($hh + $l - $nh) nut();
}
}

// EXAMPLES
/*
setenv_bolt("M5,6", "hex", trimscale=0.9)
print_bolt();

setenv_bolt("M4x0.8,8", head="button", drive="hex", ulength=0,
trimscale=1.05, z_fudge=-0.75, x0_fudge=0.5)
print_bolt(angle=53.4);

setenv_bolt("M5,6", "hex", trimscale=0.9)
nut();
//  inspect_bolt();
//  printable_bolt();
*/

[image: MiniScrews.jpg][image: DryBox.jpg][image: assembly.jpg] On Fri, Aug 9, 2024 at 9:35 PM Todd Allen <speedebikes@gmail.com> wrote: > It is easiest to print bolts vertically standing on their heads but > tensile strength is then maximally impacted by layer adhesion. Printing at > a significant angle from vertical can achieve much better tensile strength > but requires support or cutting the bolt to create a flat surface to lay on > the print bed to print horizontally. There are many cases where cutting > the bolt is not a good option and for those cases I've found it fussy to > generate support in a slicer that contacts the bolt precisely as I want to > allow for clean easy support removal. > > Here's an OpenSCAD script for creating bolts to be printed at an angle > with integrated support that I've found helpful for rapidly knocking out a > variety of fasteners with good tensile strength that take trivial clean up > effort to be ready for use. It uses BOSL2/screws.scad to create bolts. > It's quite basic with little polish and can require tweaking of a few > parameters to get best results but still I've found it very useful and > think others might too. The technique I used to generate the support could > readily be adapted to a wide range of other objects. > > If anyone knows of better approaches to printing bolts or generating > support I would love to hear about it. > > include <BOSL2/std.scad> > include <BOSL2/screws.scad> > > $fn= $preview ? 12 : 256; > eps = 0.001; > > // set trimscale sufficiently large to shave enough of the threads to > eliminate or minimize producing isolated blobs when sliced that don't print > well > // set ulength=0 for no chamfer to threaded shaft > // use x0_fudge to adjust where print_bolt() support starts on x axis > // use z_fudge to adjust z height of print_bolt() > module setenv_bolt(name, head="hex", drive="none", > ulength=undef, nut_threads=2.5, nut_diameter=0, > tolerance="6g", trimscale=1.0, slop=0.06, > zrot, x0_fudge=0, z_fudge=0, > support_thickness, support_gap = 0.15, support_ears_d, support_ears_z > = 0.2) > { > spec = screw_info(name); > $name = name; > $head = head; > $drive = drive; > $p = struct_val(spec, "pitch"); > $l = struct_val(spec, "length"); > $d = struct_val(spec, "diameter"); > $nh = $p*nut_threads+1.5; > $nd = nut_diameter ? nut_diameter : $d*1.2+4.0; > > $nut_spec = struct_set(spec, [ > "length", $nh+2*eps, > "thread_len", $nh+2*eps > ]); > > $tolerance = tolerance; > $trimscale = trimscale; > $ul = is_undef(ulength) ? $p*0.5 : ulength; // should also add in > amount tolerance spec undersizes threaded minor radius > $tl = $l - $ul; > $bolt_spec = struct_set(screw_info(name, head=head, drive=drive), [ > "thread_len", $tl > ]); > echo($bolt_spec = $bolt_spec); > > $hs = struct_val($bolt_spec, "head_size", $d); > $hh = struct_val($bolt_spec, "head_height", 0); > > $slop = slop; // $slop is parameter of BOSL2 screw_hole() > > // align hex head to rest on a flat when rotated about Y axis for > printing as headsize is across flats > // may want default angles for drive types too > auto_zrot = ($head=="hex") ? 90 : 60; > $bolt_zrot = is_undef(zrot) ? auto_zrot : zrot; > > $x0_fudge = x0_fudge; > $z_fudge = z_fudge; > $support_thickness = is_undef(support_thickness) ? 0.9+0.1*$d: > support_thickness; > $support_gap = support_gap; > $support_ears_d = is_undef(support_ears_d) ? 3+$d : support_ears_d; > $support_ears_z = support_ears_z; > > children(); > } > > module bolt() { > zrot($bolt_zrot) screw(spec=$bolt_spec, tolerance=$tolerance, > orient=DOWN, anchor=TOP); > } > > module shank_chamfer_mask(od, c) { > difference() { > zcyl(h=c, d=od+10*eps, anchor=TOP); > up(eps) zcyl(h=c+2*eps, d=od-2*c, chamfer1=-c, anchor=TOP); > } > } > > // bolt tweaked for printing with threads trimmed and end of unthreaded > shank chamfered > module printable_bolt(angle=0, z_shift=0) { > up(z_shift) yrot(angle) intersection() { > if ($ul>0) difference() { > bolt(); > up($hh+$l-$tl+eps) shank_chamfer_mask($d, $p*0.5); > } > else bolt(); > union() { > // head > zcyl(l=$hh+$l-$tl, d=$hs+3, anchor=BOT); > // trimmed shaft > up($hh+$l-$tl-eps) > cuboid([$d-$p*$trimscale,$d,$tl+eps],anchor=BOT); > } > } > } > > module print_bolt(angle=60) { > bolt_length = $hh + $l; > support_x0 = $x0_fudge + cos(angle) * $hh; > support_x1 = sin(angle) * bolt_length + cos(angle)*$d*0.5*0.40; > support_z = cos(angle) * bolt_length - sin(angle)*$d*0.4; > z_shift = (angle<=90) ? $z_fudge+sin(angle)*$hs*0.5 : > $z_fudge+max(sin(angle)*$hs*0.5, sin(angle)*$hs*0.5-cos(angle*$hh), > -cos(angle)*bolt_length+sin(angle)*$d*0.4); > matrix_from_projection = frame_map(x=RIGHT, y=UP); > matrix_to_projection = matrix_inverse(matrix_from_projection); > union() { > // support for the bolt > multmatrix(matrix_from_projection) linear_extrude(height = > $support_thickness, center=true) > difference() { > polygon([[support_x0,0], [support_x1,0], > [support_x1,support_z+z_shift], [support_x0,z_shift]]); > offset(r=$support_gap) projection(cut=true) > multmatrix(matrix_to_projection) printable_bolt(angle, z_shift); > } > // mouse ears for the support > for(x=[$support_ears_d*0.5,support_x1-$support_ears_d*0.5+0.25]) > right(x) zcyl(h=$support_ears_z, d=$support_ears_d, anchor=BOT); > // the bolt > printable_bolt(angle, z_shift); > } > } > > module nut() { > difference() { > zcyl(h=$nh, d=$nd, chamfer=$nh*0.075, $fn=6, circum=true, > anchor=BOTTOM); > down (eps) screw_hole($nut_spec, thread=true, counterbore=false, > bevel=true, anchor=BOTTOM); // , l=$nh+2*eps > } > } > > // use trimscale=0.0 in setenv_bolt() for untrimmed thread > module inspect_bolt() { > linear_extrude(height = 1) > projection(cut=true) xrot(-90) { > printable_bolt(); > up($hh + $l - $nh) nut(); > } > } > > // EXAMPLES > /* > setenv_bolt("M5,6", "hex", trimscale=0.9) > print_bolt(); > > setenv_bolt("M4x0.8,8", head="button", drive="hex", ulength=0, > trimscale=1.05, z_fudge=-0.75, x0_fudge=0.5) > print_bolt(angle=53.4); > > setenv_bolt("M5,6", "hex", trimscale=0.9) > nut(); > // inspect_bolt(); > // printable_bolt(); > */ >