Here are some 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...)
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 two optional parameters that can be used with either of these modules:
A previous version of the modules used a different approach, based on using linear_extrude() with "twist" and a thread profile in a plane normal to the threads' axis of rotation. The previous version is here. Providing enough segments to draw reasonably smooth surfaces created so many polyhedra, however, that it quickly appeared to overwhelm Openscad. ("Program error - application must close" or some such.)
The current approach, 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).
Spreadsheet. I created a spreadsheet to get data for the perpendicular-to-the-axis-cross-section of the ISO standard thread profiles. The spreadsheet is here.
Please contact me if you have any questions or suggestions.