These OpenSCAD files generate straight or tapered (pipe) threads compatible with various standards.
The example makes a 3/4" pipe nipple and a mating threaded ring.
After calibrating my printer, these print nicely and fit standard pipes and fittings nicely.
Warning: if you ask for high quality, e.g. 60 steps per turn, rendering 10 threads can take 2 hours on my computer! A simple compile and view is much faster, but may show artifacts especially at fitting ends.
I printed these with 5% infill, and I don't think they'd be water tight.
For making female threads, the program generates a "tap", the negative of what you want, which you then difference from the solid you want the tapped hole in.
For making male threads, the program generates a "die" that you difference from the pipe or cylindrical rod that you want threaded.
You can choose (US) standard 60 degree threads, or (for easier printing?) 45 degree threads (or any other angle you like--you specify the depth and pitch, which determines the angle).
Threads can be tapered, as is done for pipe threads, or uniform, as for threaded rods or bolts etc.
I couldn't find an easy way to do this in OpenSCAD, so this is a rather tedious method involving generating thin pieces of thread cross section at coordinates calculated given the thread pitch and the radius (including possible taper), using hull to make them solid in pairs, and joining all the resulting pieces.
A bevel is used at the end to make the parts nicer to insert and use.
The sharp protruding ridges of the threads are flattened slightly, as is standard, to provide some place for dirt and burrs to go without jamming the threads.
I expected to use 45 degrees for printed threads, to avoid overhang problems, but was surprised to find that 60 degree standard threads print very well on my setup (FlashForge Creator, after calibrating).