discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] building screw threads

R
robijn
Tue, Oct 27, 2015 8:44 AM

Hello,

Any chance rotate_extrude might be extended with vertical motion, in order
to make helixes?
I can imagine something workable with the following parameters:

  • amount of vertical movement per rotation
  • total number of rotations.

So if you start with a circle of diameter 1 (like for a donut) but move 2
units upwards per rotation, you get a helix with a "fill factor" of 0.5.

Implementation can be done with 2 triangular polygon per area where normally
(on a donut or so) would be 1 trapezoid polygon. I'm sorry if I don't use
the proper terms exactly, I'm not an expert in this field.

Joris

--
View this message in context: http://forum.openscad.org/building-screw-threads-tp3280p14223.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hello, Any chance rotate_extrude might be extended with vertical motion, in order to make helixes? I can imagine something workable with the following parameters: - amount of vertical movement per rotation - total number of rotations. So if you start with a circle of diameter 1 (like for a donut) but move 2 units upwards per rotation, you get a helix with a "fill factor" of 0.5. Implementation can be done with 2 triangular polygon per area where normally (on a donut or so) would be 1 trapezoid polygon. I'm sorry if I don't use the proper terms exactly, I'm not an expert in this field. Joris -- View this message in context: http://forum.openscad.org/building-screw-threads-tp3280p14223.html Sent from the OpenSCAD mailing list archive at Nabble.com.
CL
Chow Loong Jin
Tue, Oct 27, 2015 9:06 AM

On Tue, Oct 27, 2015 at 01:44:44AM -0700, robijn wrote:

Hello,

Any chance rotate_extrude might be extended with vertical motion, in order
to make helixes?
I can imagine something workable with the following parameters:

  • amount of vertical movement per rotation
  • total number of rotations.

There's linear_extrude with the twist parameter, and then there's sweep() which
gives you generalized extrusion with certain transformations. If you look at the
commit log of github.com/openscad/MCAD's fasteners/threads.scad library, you'll
see an implementation I did using linear_extrude with twist, and the current one
that uses sweep.

linear_extrude with twist generated okay meshes as long as you lined up your
facets with the twist slice back in an older version of OpenSCAD, but looks
terrible now. See https://github.com/openscad/openscad/issues/901.

[...]

--
Kind regards,
Loong Jin

On Tue, Oct 27, 2015 at 01:44:44AM -0700, robijn wrote: > Hello, > > Any chance rotate_extrude might be extended with vertical motion, in order > to make helixes? > I can imagine something workable with the following parameters: > - amount of vertical movement per rotation > - total number of rotations. There's linear_extrude with the twist parameter, and then there's sweep() which gives you generalized extrusion with certain transformations. If you look at the commit log of github.com/openscad/MCAD's fasteners/threads.scad library, you'll see an implementation I did using linear_extrude with twist, and the current one that uses sweep. linear_extrude with twist generated okay meshes as long as you lined up your facets with the twist slice back in an older version of OpenSCAD, but looks terrible now. See https://github.com/openscad/openscad/issues/901. > [...] -- Kind regards, Loong Jin
CL
Chow Loong Jin
Tue, Oct 27, 2015 9:09 AM

On Tue, Oct 27, 2015 at 05:06:07PM +0800, Chow Loong Jin wrote:

On Tue, Oct 27, 2015 at 01:44:44AM -0700, robijn wrote:

Hello,

Any chance rotate_extrude might be extended with vertical motion, in order
to make helixes?
I can imagine something workable with the following parameters:

  • amount of vertical movement per rotation
  • total number of rotations.

There's linear_extrude with the twist parameter, and then there's sweep() which
gives you generalized extrusion with certain transformations. If you look at the
commit log of github.com/openscad/MCAD's fasteners/threads.scad library, you'll
see an implementation I did using linear_extrude with twist, and the current one
that uses sweep.

linear_extrude with twist generated okay meshes as long as you lined up your
facets with the twist slice back in an older version of OpenSCAD, but looks
terrible now. See https://github.com/openscad/openscad/issues/901.

[...]

Sorry, forgot to mention that it's in the dev branch, so
https://github.com/openscad/MCAD/tree/dev/fasteners

--
Kind regards,
Loong Jin

On Tue, Oct 27, 2015 at 05:06:07PM +0800, Chow Loong Jin wrote: > On Tue, Oct 27, 2015 at 01:44:44AM -0700, robijn wrote: > > Hello, > > > > Any chance rotate_extrude might be extended with vertical motion, in order > > to make helixes? > > I can imagine something workable with the following parameters: > > - amount of vertical movement per rotation > > - total number of rotations. > > There's linear_extrude with the twist parameter, and then there's sweep() which > gives you generalized extrusion with certain transformations. If you look at the > commit log of github.com/openscad/MCAD's fasteners/threads.scad library, you'll > see an implementation I did using linear_extrude with twist, and the current one > that uses sweep. > > linear_extrude with twist generated okay meshes as long as you lined up your > facets with the twist slice back in an older version of OpenSCAD, but looks > terrible now. See https://github.com/openscad/openscad/issues/901. > > > [...] > Sorry, forgot to mention that it's in the dev branch, so https://github.com/openscad/MCAD/tree/dev/fasteners -- Kind regards, Loong Jin
CL
Chow Loong Jin
Tue, Oct 27, 2015 9:10 AM

On Tue, Oct 27, 2015 at 05:09:41PM +0800, Chow Loong Jin wrote:

On Tue, Oct 27, 2015 at 05:06:07PM +0800, Chow Loong Jin wrote:

On Tue, Oct 27, 2015 at 01:44:44AM -0700, robijn wrote:

Hello,

Any chance rotate_extrude might be extended with vertical motion, in order
to make helixes?
I can imagine something workable with the following parameters:

  • amount of vertical movement per rotation
  • total number of rotations.

There's linear_extrude with the twist parameter, and then there's sweep() which
gives you generalized extrusion with certain transformations. If you look at the
commit log of github.com/openscad/MCAD's fasteners/threads.scad library, you'll
see an implementation I did using linear_extrude with twist, and the current one
that uses sweep.

linear_extrude with twist generated okay meshes as long as you lined up your
facets with the twist slice back in an older version of OpenSCAD, but looks
terrible now. See https://github.com/openscad/openscad/issues/901.

[...]

Sorry, forgot to mention that it's in the dev branch, so
https://github.com/openscad/MCAD/tree/dev/fasteners

On Tue, Oct 27, 2015 at 05:09:41PM +0800, Chow Loong Jin wrote: > On Tue, Oct 27, 2015 at 05:06:07PM +0800, Chow Loong Jin wrote: > > On Tue, Oct 27, 2015 at 01:44:44AM -0700, robijn wrote: > > > Hello, > > > > > > Any chance rotate_extrude might be extended with vertical motion, in order > > > to make helixes? > > > I can imagine something workable with the following parameters: > > > - amount of vertical movement per rotation > > > - total number of rotations. > > > > There's linear_extrude with the twist parameter, and then there's sweep() which > > gives you generalized extrusion with certain transformations. If you look at the > > commit log of github.com/openscad/MCAD's fasteners/threads.scad library, you'll > > see an implementation I did using linear_extrude with twist, and the current one > > that uses sweep. > > > > linear_extrude with twist generated okay meshes as long as you lined up your > > facets with the twist slice back in an older version of OpenSCAD, but looks > > terrible now. See https://github.com/openscad/openscad/issues/901. > > > > > [...] > > > > Sorry, forgot to mention that it's in the dev branch, so > https://github.com/openscad/MCAD/tree/dev/fasteners Umm, I mean https://github.com/openscad/MCAD/blob/dev/fasteners/threads.scad -- Kind regards, Loong Jin
JR
Joris Robijn
Tue, Oct 27, 2015 11:21 AM

I understand you can make similar things with linear_extrude. But the polygons will be
completely different and it will not look nearly as good. If you use linear_extrude with a lot of
rotations, the polygons will be very long stretched. You don't want this on threads. Many more
polygons are then needed to create something that looks reasonable acceptable. Rendering
times are 10 times what is actually be needed. And still it's not really good.

Also, conceptually, it is a different way of creating things. In the real world, extrusion
machines don't make threads, and there's a good reason for it: the angle cannot be that
great. To make a thread, you would place a shape at 90 degrees onto the work, like a cutter
on a lathe. You are shaping from a different angle.

The thread library is very nice, but the library could also be a lot easier if this type of rotating
extrusion would be natively supported. You would only need to use the following code to
make a nearly perfect thread:

module metric_thread( diameter, length, pitch );
intersection() {
translate( [0, 0, -pitch] )
// create a thread from a polygon
rotate_extrude( pitch=pitch, rotations=length/pitch+2 )
polygon( points=[
[0,0],
[diameter,0],
[diameter, pitch1/16],
[diameter-5/16
sqrt(3)pitch, pitch6/16],
[diameter-5/16sqrt(3)pitch, pitch10/16],
[diameter, pitch
15/16],
[diameter, pitch],
[0, pitch], ] );
// cut off the thread at top and bottom by intersecting with this cube
translate( [-diameter/2, -diameter/2,0] )
cube( [diameter,diameter,length] );
}
}

On 27 Oct 2015 at 2:11, Chow Loong Jin [via OpenSCAD] wrote:

On Tue, Oct 27, 2015 at 05:09:41PM +0800, Chow Loong Jin wrote:

On Tue, Oct 27, 2015 at 05:06:07PM +0800, Chow Loong Jin wrote:

On Tue, Oct 27, 2015 at 01:44:44AM -0700, robijn wrote:

Hello,

Any chance rotate_extrude might be extended with vertical

motion, in order

to make helixes?
I can imagine something workable with the following

parameters:

  • amount of vertical movement per rotation
  • total number of rotations.

There's linear_extrude with the twist parameter, and then

there's sweep() which

gives you generalized extrusion with certain transformations. If

you look at the

commit log of github.com/openscad/MCAD's fasteners/threads.scad

library, you'll

see an implementation I did using linear_extrude with twist, and

the current one

that uses sweep.

linear_extrude with twist generated okay meshes as long as you

lined up your

facets with the twist slice back in an older version of

OpenSCAD, but looks

terrible now. See

[...]

Sorry, forgot to mention that it's in the dev branch, so
https://github.com/openscad/MCAD/tree/dev/fasteners

Umm, I mean
https://github.com/openscad/MCAD/blob/dev/fasteners/threads.scad

--
Kind regards,
Loong Jin


OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.or
g

signature.asc (836 bytes) Download Attachment

If you reply to this email, your message will be added to the
discussion below:
http://forum.openscad.org/building-screw-threads-tp3280p14226.html
To unsubscribe from building screw threads, click here.
NAML

I understand you can make similar things with linear_extrude. But the polygons will be completely different and it will not look nearly as good. If you use linear_extrude with a lot of rotations, the polygons will be very long stretched. You don't want this on threads. Many more polygons are then needed to create something that looks reasonable acceptable. Rendering times are 10 times what is actually be needed. And still it's not really good. Also, conceptually, it is a different way of creating things. In the real world, extrusion machines don't make threads, and there's a good reason for it: the angle cannot be that great. To make a thread, you would place a shape at 90 degrees onto the work, like a cutter on a lathe. You are shaping from a different angle. The thread library is very nice, but the library could also be a lot easier if this type of rotating extrusion would be natively supported. You would only need to use the following code to make a nearly perfect thread: module metric_thread( diameter, length, pitch ); intersection() { translate( [0, 0, -pitch] ) // create a thread from a polygon rotate_extrude( pitch=pitch, rotations=length/pitch+2 ) polygon( points=[ [0,0], [diameter,0], [diameter, pitch*1/16], [diameter-5/16*sqrt(3)*pitch, pitch*6/16], [diameter-5/16*sqrt(3)*pitch, pitch*10/16], [diameter, pitch*15/16], [diameter, pitch], [0, pitch], ] ); // cut off the thread at top and bottom by intersecting with this cube translate( [-diameter/2, -diameter/2,0] ) cube( [diameter,diameter,length] ); } } On 27 Oct 2015 at 2:11, Chow Loong Jin [via OpenSCAD] wrote: > > On Tue, Oct 27, 2015 at 05:09:41PM +0800, Chow Loong Jin wrote: > > > On Tue, Oct 27, 2015 at 05:06:07PM +0800, Chow Loong Jin wrote: > > > On Tue, Oct 27, 2015 at 01:44:44AM -0700, robijn wrote: > > > > Hello, > > > > > > > > Any chance rotate_extrude might be extended with vertical > motion, in order > > > > to make helixes? > > > > I can imagine something workable with the following > parameters: > > > > - amount of vertical movement per rotation > > > > - total number of rotations. > > > > > > There's linear_extrude with the twist parameter, and then > there's sweep() which > > > gives you generalized extrusion with certain transformations. If > you look at the > > > commit log of github.com/openscad/MCAD's fasteners/threads.scad > library, you'll > > > see an implementation I did using linear_extrude with twist, and > the current one > > > that uses sweep. > > > > > > linear_extrude with twist generated okay meshes as long as you > lined up your > > > facets with the twist slice back in an older version of > OpenSCAD, but looks > > > terrible now. See > https://github.com/openscad/openscad/issues/901. > > > > > > > [...] > > > > > > > Sorry, forgot to mention that it's in the dev branch, so > > https://github.com/openscad/MCAD/tree/dev/fasteners > Umm, I mean > https://github.com/openscad/MCAD/blob/dev/fasteners/threads.scad > > -- > Kind regards, > Loong Jin > > _______________________________________________ > OpenSCAD mailing list > [hidden email] > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.or > g > > signature.asc (836 bytes) Download Attachment > > > > > If you reply to this email, your message will be added to the > discussion below: > http://forum.openscad.org/building-screw-threads-tp3280p14226.html > To unsubscribe from building screw threads, click here. > NAML
CL
Chow Loong Jin
Tue, Oct 27, 2015 1:09 PM

On Tue, Oct 27, 2015 at 12:21:11PM +0100, Joris Robijn wrote:

[...]
module metric_thread( diameter, length, pitch );
intersection() {
translate( [0, 0, -pitch] )
// create a thread from a polygon
rotate_extrude( pitch=pitch, rotations=length/pitch+2 )
polygon( points=[
[0,0],
[diameter,0],
[diameter, pitch1/16],
[diameter-5/16
sqrt(3)pitch, pitch6/16],
[diameter-5/16sqrt(3)pitch, pitch10/16],
[diameter, pitch
15/16],
[diameter, pitch],
[0, pitch], ] );
// cut off the thread at top and bottom by intersecting with this cube
translate( [-diameter/2, -diameter/2,0] )
cube( [diameter,diameter,length] );
}
}

This snippet could possibly be abstracted out into a module to do what you want.
https://github.com/openscad/MCAD/blob/dev/fasteners/threads.scad#L202

--
Kind regards,
Loong Jin

On Tue, Oct 27, 2015 at 12:21:11PM +0100, Joris Robijn wrote: > [...] > module metric_thread( diameter, length, pitch ); > intersection() { > translate( [0, 0, -pitch] ) > // create a thread from a polygon > rotate_extrude( pitch=pitch, rotations=length/pitch+2 ) > polygon( points=[ > [0,0], > [diameter,0], > [diameter, pitch*1/16], > [diameter-5/16*sqrt(3)*pitch, pitch*6/16], > [diameter-5/16*sqrt(3)*pitch, pitch*10/16], > [diameter, pitch*15/16], > [diameter, pitch], > [0, pitch], ] ); > // cut off the thread at top and bottom by intersecting with this cube > translate( [-diameter/2, -diameter/2,0] ) > cube( [diameter,diameter,length] ); > } > } This snippet could possibly be abstracted out into a module to do what you want. https://github.com/openscad/MCAD/blob/dev/fasteners/threads.scad#L202 -- Kind regards, Loong Jin
MK
Marius Kintel
Tue, Oct 27, 2015 1:41 PM

On Oct 27, 2015, at 04:44 AM, robijn joris@robijn.net wrote:

Any chance rotate_extrude might be extended with vertical motion, in order
to make helixes?

I like the idea of modifying rotate_extrude to allow for building helixes, although it’s a step backwards from providing more general extrusion functionality..

-Marius

> On Oct 27, 2015, at 04:44 AM, robijn <joris@robijn.net> wrote: > > Any chance rotate_extrude might be extended with vertical motion, in order > to make helixes? I like the idea of modifying rotate_extrude to allow for building helixes, although it’s a step backwards from providing more general extrusion functionality.. -Marius
R
robijn
Fri, Oct 14, 2016 10:14 AM

Any chance this might make it in a future release? I'm running into this again now, and I don't like to the use libraries for this
basic lathe functionality.
Would it be easy for me (having some C++ experience) to add it myself?

Best regards,
Joris

On 27 Oct 2015 at 6:42, kintel [via OpenSCAD] wrote:

On Oct 27, 2015, at 04:44 AM, robijn <[hidden email]> wrote:

Any chance rotate_extrude might be extended with vertical motion, in order
to make helixes?

I like the idea of modifying rotate_extrude to allow for building helixes, although it's a step backwards from providing more
general extrusion functionality..

 -Marius


OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/building-screw-threads-tp3280p14230.html
To unsubscribe from building screw threads, click here.
NAML

--
Joris Robijn joris@rubytech.nl
www.rubytech.nl
www.videoregie.nl
Eindhoven, The Netherlands
Phone: +31 6 288 41 964

--
View this message in context: http://forum.openscad.org/building-screw-threads-tp3280p18704.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Any chance this might make it in a future release? I'm running into this again now, and I don't like to the use libraries for this basic lathe functionality. Would it be easy for me (having some C++ experience) to add it myself? Best regards, Joris On 27 Oct 2015 at 6:42, kintel [via OpenSCAD] wrote: > On Oct 27, 2015, at 04:44 AM, robijn <[hidden email]> wrote: > > Any chance rotate_extrude might be extended with vertical motion, in order > to make helixes? I like the idea of modifying rotate_extrude to allow for building helixes, although it's a step backwards from providing more general extrusion functionality..  -Marius _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org If you reply to this email, your message will be added to the discussion below: http://forum.openscad.org/building-screw-threads-tp3280p14230.html To unsubscribe from building screw threads, click here. NAML -- Joris Robijn <joris@rubytech.nl> www.rubytech.nl www.videoregie.nl Eindhoven, The Netherlands Phone: +31 6 288 41 964 -- View this message in context: http://forum.openscad.org/building-screw-threads-tp3280p18704.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JR
Joris Robijn
Fri, Oct 14, 2016 10:15 AM

Any chance this might make it in a future release? I'm running into this again now, and I don't like to the use libraries for this
basic lathe functionality.
Would it be easy for me (having some C++ experience) to add it myself?

Best regards,
Joris

On 27 Oct 2015 at 6:42, kintel [via OpenSCAD] wrote:

On Oct 27, 2015, at 04:44 AM, robijn <[hidden email]> wrote:

Any chance rotate_extrude might be extended with vertical motion, in order
to make helixes?

I like the idea of modifying rotate_extrude to allow for building helixes, although it's a step backwards from providing more
general extrusion functionality..

 -Marius


OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/building-screw-threads-tp3280p14230.html
To unsubscribe from building screw threads, click here.
NAML

--
Joris Robijn joris@rubytech.nl
www.rubytech.nl
www.videoregie.nl
Eindhoven, The Netherlands
Phone: +31 6 288 41 964

Any chance this might make it in a future release? I'm running into this again now, and I don't like to the use libraries for this basic lathe functionality. Would it be easy for me (having some C++ experience) to add it myself? Best regards, Joris On 27 Oct 2015 at 6:42, kintel [via OpenSCAD] wrote: > On Oct 27, 2015, at 04:44 AM, robijn <[hidden email]> wrote: > > Any chance rotate_extrude might be extended with vertical motion, in order > to make helixes? I like the idea of modifying rotate_extrude to allow for building helixes, although it's a step backwards from providing more general extrusion functionality..  -Marius _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org If you reply to this email, your message will be added to the discussion below: http://forum.openscad.org/building-screw-threads-tp3280p14230.html To unsubscribe from building screw threads, click here. NAML -- Joris Robijn <joris@rubytech.nl> www.rubytech.nl www.videoregie.nl Eindhoven, The Netherlands Phone: +31 6 288 41 964
MK
Marius Kintel
Fri, Oct 14, 2016 1:16 PM

On Oct 14, 2016, at 06:15, Joris Robijn joris@robijn.net wrote:

Any chance this might make it in a future release? I'm running into this again now, and I don't like to the use libraries for this basic lathe functionality.

Would it be easy for me (having some C++ experience) to add it myself?

It’s trivial to add the basic functionality.
Dealing with the public interface, corner cases and testing to get it accepted into OpenSCAD takes a bit more effort.

One idea could be to introduce a new built-in module for this; lathe() or helix() or smth.. That way we can leave rotate_extrude() alone. We still need to be careful as we have to maintain this function in the future.
Hopefully, in the future it would be possible to implement such a module in pure openscad.

-Marius

> On Oct 14, 2016, at 06:15, Joris Robijn <joris@robijn.net> wrote: > > Any chance this might make it in a future release? I'm running into this again now, and I don't like to the use libraries for this basic lathe functionality. > > Would it be easy for me (having some C++ experience) to add it myself? > It’s trivial to add the basic functionality. Dealing with the public interface, corner cases and testing to get it accepted into OpenSCAD takes a bit more effort. One idea could be to introduce a new built-in module for this; lathe() or helix() or smth.. That way we can leave rotate_extrude() alone. We still need to be careful as we have to maintain this function in the future. Hopefully, in the future it would be possible to implement such a module in pure openscad. -Marius