openscad screw threads with linear_extrude by speedymollusc 3d model
3dmdb logo
Thingiverse
openscad screw threads with linear_extrude by speedymollusc

openscad screw threads with linear_extrude by speedymollusc

by Thingiverse
Last crawled date: 2 years, 12 months ago
It's always bugged me that you can't make screw threads easily with openscad's linear_extrude - and then I realized, on my bike ride home from work, that actually you can!
.
The main problem is that people usually think of a screw thread in terms of a vertical cross section, but openscad needs a horizontal cross-section for linear extrusion. But this isn't a fundamental limitation, it's a failure of imagination! So imagine cutting a screw in half with a hacksaw. Look at the shape the cut made. If you were to linearly extrude the resulting shape, with the correct twist, then you'd get the screw back, right? So we just have to figure out what the shape of that cross-section is.
.
Fortunately we can do that natively in openscad, basically by running the game backwards: make a doughnut the shape of the thread, cut it in a spiral, and look at it from above - that's your shape.
.
More rigorously: If P is the polygon you want to extrude as a thread, first of all rotationally extrude it, to get a P-shaped torus. Then intersect the torus with a helicoid of the same pitch as the threads you want (but the opposite orientation). A helicoid is what you get when you linear_extrude a thin stick, with a twist, so both of these shapes are easy to make in openscad. Now take the result of this intersection and project it onto the xy plane. This is the cross-section of the screw we were looking for. Nifty, yes?
.
I'm not saying it's efficient, or smart, or pretty, or better than any of the screw libraries - I'm just saying it's possible, and in fact conceptually simple.
.
However, I have one more observation: if you start with a polygonal thread shape and transform it as above, then the transformation I've described seems like it might just be a two-dimensional geometric inversion in some point. Under inversions, straight lines turn into circular arcs... so there's likely to be a way smarter way to do this transformation mathematically, without going through openscad's 3D system at all! Stay tuned...
.Edit: not really sure why thingview is showing a solid cylinder... but I did notice that openscad was doing something similar if I made any of the extrusions use too many slices. Like I said, it ain't pretty yet.

Tags