discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Problem with linear&rotate_exrude

MF
mike.fraser.1945+osc@gmail.com
Fri, Oct 18, 2024 3:39 PM

I am trying to add a simple thread to an air hose fitting.  My thought was to create a helix of circular cross-section, then union that on the surface of a cylinder.  The following creates the helix but it seems to have zero cross-section.

linear_extrude(height=1.5*INCH,v=[0,0,1], twist =3*360, convexity=10, $fn=180)

translate(\[1.16\*INCH, 0, 0\]) circle(d=3) ;

Whereas the following creates a nice hollow toroid.

rotate_extrude(convexity = 10)  translate([Radius, 0, 0])

difference(){

circle(r = Outer);

circle(r=Inner) ;

I do not seem to be able to get both cross-section & helix in the same statements.

What am I doing wrong?  Please educate me yet again.

Mike

I am trying to add a simple thread to an air hose fitting. My thought was to create a helix of circular cross-section, then union that on the surface of a cylinder. The following creates the helix but it seems to have zero cross-section. linear_extrude(height=1.5\*INCH,v=\[0,0,1\], twist =3\*360, convexity=10, $fn=180) translate(\[1.16\*INCH, 0, 0\]) circle(d=3) ; Whereas the following creates a nice hollow toroid. rotate_extrude(convexity = 10) translate(\[Radius, 0, 0\]) difference(){ circle(r = Outer); circle(r=Inner) ; I do not seem to be able to get both cross-section & helix in the same statements. What am I doing wrong? Please educate me yet again. Mike
TA
Todd Allen
Sat, Oct 19, 2024 1:39 AM

Maybe try BOSL2's thread_helix() or generic_threaded_rod()?

On Fri, Oct 18, 2024 at 7:54 PM mike.fraser.1945+osc--- via Discuss <
discuss@lists.openscad.org> wrote:

I am trying to add a simple thread to an air hose fitting. My thought was
to create a helix of circular cross-section, then union that on the surface
of a cylinder. The following creates the helix but it seems to have zero
cross-section.

linear_extrude(height=1.5INCH,v=[0,0,1], twist =3360, convexity=10,
$fn=180)

translate([1.16*INCH, 0, 0]) circle(d=3) ;

Whereas the following creates a nice hollow toroid.

rotate_extrude(convexity = 10) translate([Radius, 0, 0])

difference(){

circle(r = Outer);

circle(r=Inner) ;

I do not seem to be able to get both cross-section & helix in the same
statements.

What am I doing wrong? Please educate me yet again.

Mike


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

Maybe try BOSL2's thread_helix() or generic_threaded_rod()? On Fri, Oct 18, 2024 at 7:54 PM mike.fraser.1945+osc--- via Discuss < discuss@lists.openscad.org> wrote: > I am trying to add a simple thread to an air hose fitting. My thought was > to create a helix of circular cross-section, then union that on the surface > of a cylinder. The following creates the helix but it seems to have zero > cross-section. > > linear_extrude(height=1.5*INCH,v=[0,0,1], twist =3*360, convexity=10, > $fn=180) > > translate([1.16*INCH, 0, 0]) circle(d=3) ; > > Whereas the following creates a nice hollow toroid. > > rotate_extrude(convexity = 10) translate([Radius, 0, 0]) > > difference(){ > > circle(r = Outer); > > circle(r=Inner) ; > > I do not seem to be able to get both cross-section & helix in the same > statements. > > What am I doing wrong? Please educate me yet again. > > Mike > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Sat, Oct 19, 2024 1:48 AM

The simple answer is that it's possible but difficult to create a helix
with linear_extrude, and not possible with rotate_extrude.

Covering rotate_extrude first:  there's no way to move vertically during
the extrusion; the result is always rotationally symmetric.

It's a bit harder to explain why linear extrusion isn't useful for
building helixes.

Linear extrusion works by taking the shape that you give it, aligned on
the XY plane, moving and modifying it as controlled by the arguments,
connecting the two, and repeating.  The horizontal cross-section of the
resulting shape is thus always a copy (perhaps as modified by scale and
twist) of the original shape.  If you linear extrude a circle (and don't
impose a scale, because that confuses the issue), every horizontal
cross-section all the way up will be a circle.

Helixes don't have horizontal cross-sections that are circles.  They
have horizontal cross-sections that are sort of banana-shaped. 
(Visualize a spring, then cut horizontally across it.)

You can build a helix with linear extrusion, but you have to start
with that banana-shaped cross section, and that's a pain in the neck to
derive.

To generate a true helix, you want a tilted extrusion, that rotates
the original shape with its "up" pointed along the helix.  But base
OpenSCAD doesn't have that.  (You might think that "v" provides it, but
that translates the shape as it extrudes; it doesn't tilt the shape.)

Theoretically, even a rotational extrude that can translate vertically
will have trouble generating a helix, for much the same reason.  A
vertical cross-section of a helix isn't a circle either.  That's less
apparent for a compact helix like a spring, but more obvious if you look
at an elongated one.

However, I've been told that screw threads are not proper helixes, that
they are defined in terms of a vertical cross-section.  A rotational
extrusion with "translate" capability would be able to build such a
thing, but we don't have that.

The DIY-ish answer is to use a "sweep" function from your favorite library.

The easiest answer is probably to note that you aren't the first person
who wants to print a threaded thing, and look for a library that does it
for you.  I believe there are several such libraries, but the one that I
would look at first is BOSL2 because it also has a ton (that is, 2000
lbs or 1000 kg) of other features.  Look at
https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad .

Here's a writeup I did a while back on the banana-extrusion option. 
It's not the first on the subject.  (I know that somebody else described
the same technique independently and earlier, but I'm not immediately
finding it.)
https://lists.openscad.org/empathy/thread/F6ZABTOSYPR7WNFCXABFFMIIKSMI4LO3

The simple answer is that it's possible but difficult to create a helix with linear_extrude, and not possible with rotate_extrude. Covering rotate_extrude first:  there's no way to move vertically during the extrusion; the result is always rotationally symmetric. It's a bit harder to explain why linear extrusion isn't useful for building helixes. Linear extrusion works by taking the shape that you give it, aligned on the XY plane, moving and modifying it as controlled by the arguments, connecting the two, and repeating.  The horizontal cross-section of the resulting shape is thus always a copy (perhaps as modified by scale and twist) of the original shape.  If you linear extrude a circle (and don't impose a scale, because that confuses the issue), every horizontal cross-section all the way up will be a circle. Helixes don't have horizontal cross-sections that are circles.  They have horizontal cross-sections that are sort of banana-shaped.  (Visualize a spring, then cut horizontally across it.) You *can* build a helix with linear extrusion, but you have to start with that banana-shaped cross section, and that's a pain in the neck to derive. To generate a true helix, you want a *tilted* extrusion, that rotates the original shape with its "up" pointed along the helix.  But base OpenSCAD doesn't have that.  (You might think that "v" provides it, but that translates the shape as it extrudes; it doesn't tilt the shape.) Theoretically, even a rotational extrude that can translate vertically will have trouble generating a helix, for much the same reason.  A *vertical* cross-section of a helix isn't a circle either.  That's less apparent for a compact helix like a spring, but more obvious if you look at an elongated one. However, I've been told that screw threads are not proper helixes, that they are defined in terms of a vertical cross-section.  A rotational extrusion with "translate" capability would be able to build such a thing, but we don't have that. The DIY-ish answer is to use a "sweep" function from your favorite library. The easiest answer is probably to note that you aren't the first person who wants to print a threaded thing, and look for a library that does it for you.  I believe there are several such libraries, but the one that I would look at first is BOSL2 because it also has a ton (that is, 2000 lbs or 1000 kg) of other features.  Look at https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad . Here's a writeup I did a while back on the banana-extrusion option.  It's not the first on the subject.  (I know that somebody else described the same technique independently and earlier, but I'm not immediately finding it.) https://lists.openscad.org/empathy/thread/F6ZABTOSYPR7WNFCXABFFMIIKSMI4LO3
RW
Raymond West
Sat, Oct 19, 2024 10:31 AM

I put the code that I use, in reply to Mike's first query on 14th. It
can't get much simpler than that. The result is plenty good enough for
consumer standard 3d printing. For metric threads I use Nophead's
library. In cadquery, you can put the shape in xy plane, and extrude in
z, which sometimes can give a better profile, but cadquery has other
problems.

When it comes to machining threads with a single point lathe tool, they
are, for metric, ground at 60 degrees, but with a flat top surface (that
is easy, like the rest of the abomination that is the metric thread
profile). Strictly speaking, the 60 degree should be perpendicular to
the helix angle, but generally the error is not worth bothering about.
The error in thread angle, means that if you also use a single point
tool for the internal thread, in theory, the nut will only have the
correct matching profile in one orientation. But, some things are just
not worth bothering about, until they are...

On 19/10/2024 02:48, Jordan Brown via Discuss wrote:

The simple answer is that it's possible but difficult to create a
helix with linear_extrude, and not possible with rotate_extrude.

Covering rotate_extrude first:  there's no way to move vertically
during the extrusion; the result is always rotationally symmetric.

It's a bit harder to explain why linear extrusion isn't useful for
building helixes.

Linear extrusion works by taking the shape that you give it, aligned
on the XY plane, moving and modifying it as controlled by the
arguments, connecting the two, and repeating.  The horizontal
cross-section of the resulting shape is thus always a copy (perhaps as
modified by scale and twist) of the original shape. If you linear
extrude a circle (and don't impose a scale, because that confuses the
issue), every horizontal cross-section all the way up will be a circle.

Helixes don't have horizontal cross-sections that are circles. They
have horizontal cross-sections that are sort of banana-shaped. 
(Visualize a spring, then cut horizontally across it.)

You can build a helix with linear extrusion, but you have to start
with that banana-shaped cross section, and that's a pain in the neck
to derive.

To generate a true helix, you want a tilted extrusion, that rotates
the original shape with its "up" pointed along the helix. But base
OpenSCAD doesn't have that.  (You might think that "v" provides it,
but that translates the shape as it extrudes; it doesn't tilt the shape.)

Theoretically, even a rotational extrude that can translate vertically
will have trouble generating a helix, for much the same reason.  A
vertical cross-section of a helix isn't a circle either.  That's
less apparent for a compact helix like a spring, but more obvious if
you look at an elongated one.

However, I've been told that screw threads are not proper helixes,
that they are defined in terms of a vertical cross-section.  A
rotational extrusion with "translate" capability would be able to
build such a thing, but we don't have that.

The DIY-ish answer is to use a "sweep" function from your favorite
library.

The easiest answer is probably to note that you aren't the first
person who wants to print a threaded thing, and look for a library
that does it for you.  I believe there are several such libraries, but
the one that I would look at first is BOSL2 because it also has a ton
(that is, 2000 lbs or 1000 kg) of other features.  Look at
https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad .

Here's a writeup I did a while back on the banana-extrusion option. 
It's not the first on the subject.  (I know that somebody else
described the same technique independently and earlier, but I'm not
immediately finding it.)
https://lists.openscad.org/empathy/thread/F6ZABTOSYPR7WNFCXABFFMIIKSMI4LO3


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

I put the code that I use, in reply to Mike's first query on 14th. It can't get much simpler than that. The result is plenty good enough for consumer standard 3d printing. For metric threads I use Nophead's library. In cadquery, you can put the shape in xy plane, and extrude in z, which sometimes can give a better profile, but cadquery has other problems. When it comes to machining threads with a single point lathe tool, they are, for metric, ground at 60 degrees, but with a flat top surface (that is easy, like the rest of the abomination that is the metric thread profile). Strictly speaking, the 60 degree should be perpendicular to the helix angle, but generally the error is not worth bothering about. The error in thread angle, means that if you also use a single point tool for the internal thread, in theory, the nut will only have the correct matching profile in one orientation. But, some things are just not worth bothering about, until they are... On 19/10/2024 02:48, Jordan Brown via Discuss wrote: > The simple answer is that it's possible but difficult to create a > helix with linear_extrude, and not possible with rotate_extrude. > > Covering rotate_extrude first:  there's no way to move vertically > during the extrusion; the result is always rotationally symmetric. > > It's a bit harder to explain why linear extrusion isn't useful for > building helixes. > > Linear extrusion works by taking the shape that you give it, aligned > on the XY plane, moving and modifying it as controlled by the > arguments, connecting the two, and repeating.  The horizontal > cross-section of the resulting shape is thus always a copy (perhaps as > modified by scale and twist) of the original shape. If you linear > extrude a circle (and don't impose a scale, because that confuses the > issue), every horizontal cross-section all the way up will be a circle. > > Helixes don't have horizontal cross-sections that are circles. They > have horizontal cross-sections that are sort of banana-shaped.  > (Visualize a spring, then cut horizontally across it.) > > You *can* build a helix with linear extrusion, but you have to start > with that banana-shaped cross section, and that's a pain in the neck > to derive. > > To generate a true helix, you want a *tilted* extrusion, that rotates > the original shape with its "up" pointed along the helix. But base > OpenSCAD doesn't have that.  (You might think that "v" provides it, > but that translates the shape as it extrudes; it doesn't tilt the shape.) > > Theoretically, even a rotational extrude that can translate vertically > will have trouble generating a helix, for much the same reason.  A > *vertical* cross-section of a helix isn't a circle either.  That's > less apparent for a compact helix like a spring, but more obvious if > you look at an elongated one. > > However, I've been told that screw threads are not proper helixes, > that they are defined in terms of a vertical cross-section.  A > rotational extrusion with "translate" capability would be able to > build such a thing, but we don't have that. > > The DIY-ish answer is to use a "sweep" function from your favorite > library. > > The easiest answer is probably to note that you aren't the first > person who wants to print a threaded thing, and look for a library > that does it for you.  I believe there are several such libraries, but > the one that I would look at first is BOSL2 because it also has a ton > (that is, 2000 lbs or 1000 kg) of other features.  Look at > https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad . > > Here's a writeup I did a while back on the banana-extrusion option.  > It's not the first on the subject.  (I know that somebody else > described the same technique independently and earlier, but I'm not > immediately finding it.) > https://lists.openscad.org/empathy/thread/F6ZABTOSYPR7WNFCXABFFMIIKSMI4LO3 > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org