This is a fast and flexible thread-profile generator for OpenSCAD.
- It makes frugal, consistent, sound meshes.
- It makes undistorted NPT theads!
- It obeys $fs/$fa/$fn.
- It uses arbitrary profiles - i.e. the difference between UTS and ACME is a variable.
- It does multi-start threads.
- It can compensate for printing steep pitches like ACME.
As usual, all this stuff also lives on my site: http://burningsmell.org/3d/lib/tsmthread/
// 5/8" 11TPI imperial threads, 3/4" long, ordinary thread profile
imperial() tsmthread(DMAJ=5/8+$OD_COMP, PITCH=1/11, L=3/4, PR=THREAD_UTS);
// TR30x3 trapezoidal threads
translate([50,0]) tsmthread(DMAJ=30+$OD_COMP, PITCH=3, L=59, PR=THREAD_TRAP);
// TR8 thread, 2mm pitch, 4 start
translate([0,50]) tsmthread(DMAJ=8+$OD_COMP, L=10, PITCH=2, PR=THREAD_TRAP, STARTS=4);
// Experimental: compensated leadscrew threads. Angle and depth must be specified.
comp_thread(DMAJ=9+$OD_COMP, L=5, PITCH=2, STARTS=4, A=30, H1=0.25, H2=0.25);
I have tested every single included object. No special print settings were used, just Cura fast or medium.
I printed on a lulzbot taz 6, not a lulzbot taz mini 2 as Thingiverse insisted on me selecting.
Gosh this was a slog. I've got misprint pipe-adapters coming out my ears!
There's so many thread libraries on Thingiverse you'd think this would be a solved problem by now. There's just a few niggling parts of each. Some are slow. Some only generate one kind of thread, only single-start threads, or makeshift profiles which kind-of work. Some generate over-complicated meshes, contain topological problems which explode when sliced, etc. This is my attempted solution.
How it Really Works
This implements the tempting but difficult "naive" method of generating screw threads: Spin the profile in an almost-circle, calculate flat ends, and stitch all holes in the mesh. This is done in pure math - no time-consuming CSG operations are used.
Doing it the hard way has the advantage that it can switch thread profiles as easily as switching variables, and include taper naturally.
Calculated Profile vs Ideal Triangles
Taper is calculated by adding a steady amount to the radius. This inevitably distorts the teeth, but does so in a completely predictable way. Subtracting this distortion from the profile creates a profile with perfect angles.
It's possible to generate perfect thread profiles which just don't fit.
As an experimental feature, this library includes the ability to print narrower teeth which mesh better without being as severely over/under size. This is only meant for leadscrews.
Leadscrews and their steeply pitched teeth tend to print thicker than they're supposed to. Traditionally they've been printed over/under diameter, but their steep teeth means the over/under sizing needs to be extreme, and results in only the very tips of their teeth coming in contact. Thinning the teeth permits a better fit with less oversize.
This concave profile cannot be constructed.
Why can't a "drillbit" thread be made in tsmthread? Because it's concave. Plot radius as a function of angle, and angle will sometimes go backwards! tsmthread's interpolation cannot accommodate this kind of curve.