Updated 2025-10-08. Ver 3.0; add script URL (thanks, VOlker Philippent).
Here are modules to draw accurate, ISO-standard threads in OpenSCAD. The specification comes from Wikipedia.
The modules file is downloadable here.
(Right-click and Save Link As...)
tarball
(cd8df981183b9e00f781987b39c05acc)
There are two front-end modules:
metric_thread() input units are millimeters. english_thread() inputs are in inches, though the drawing dimensions are in millimeters.
There are several optional parameters that can be used with either of these modules:
square=true. (default: false). Standard square threads (per
Wikipedia).
thread_size=N. (default: same as pitch). Non-standard. This option allows the
size of a single thread "V" to be specified independently of the pitch
("travel" per turn). In this example, the pitch is 4 mm, but the thread size is 1 mm.
groove=true. (default: false) Non-standard. Draws the thread as an
inverted "V" subtracted from the "bolt cylinder". In this example, the pitch is 4 mm and the
thread size is 1 mm (as in the previous example), but groove is set true.
rectangle=RATIO. (default: 1). Non-standard. Specifies a "square" thread that is
actually a rectangle. In this example, rectangle=0.333 - the "height" of the thread is
one-third of its "width." In addition, the pitch is 8 mm while the
thread size is 6 mm, and groove is set to true.
Note: left-hand threads. While there is no option for left-hand threads, such "reverse" threads are easy to create in OpenSCAD – use the "mirror" command to "flip" the part across a plane.
This module, which uses a polyhedron for each segment of the thread, was inspired by Trevor Moseley's work, although the results there do not appear to adhere to the ISO standards (especially with regard to required clearances).
Please contact me if you have any questions or suggestions.