Sandbox:DeepSOIC

Introduction
This tutorial is a collection of techniques to model screw threads in FreeCAD.

Modeling threads is discouraged, because it puts big load on modeling kernel, as well as on rendering side. Thread shapes take a lot of memory, and having just one thread in a FreeCAD project can easily blow the file size into megabyte range. However, there are some situations, where it is essential to model the thread to its full details, and this is what the tutorial is for.

Method 0. Obtain one from library of parts
Using models that other people have made is easy and saves time. Check out Macro BOLTS, which is an interface for inserting standard parts from BOLTS library.

Method 1. Using macros.
There is a famous Screw Maker macro, made by ulrich1a, and a whole Fasteners Workbench made by shaise (link to GitHub). These have an option to generate a thread. These are aimed at standard thread profiles (triangular-ish).

Method 2. Cheating by stacking disks.
This is a very good way for visualizing threads, yet keeping the geometry simple.

The idea is to create a non-helical thread (which is just a revolution of a sawtooth profile, or a stack of disks with tapered edges). Such a fake thread is hard to tell apart from the real helical one by just looking at it. This may work for FEM, too. However, if you want to 3d-print it, this isn't going to work.



Idea
The idea is pretty simple: draw the profile of the thread, and then sweep it along a helix. When sweeping, make sure to tick Solid and Frenet checkboxes. Solid is the key to be able to perform fuse or cut operations on it. Frenet will keep the profile from twisting (more info on that is available in Part Sweep documentation).

This generates a coil of the thread, without the rod or the hole. To make a thread on a rod or a hole, one has to fuse or cut this coil with a cylinder. Additional Boolean operations are needed to shape up the ugly abrupt ends of the coil.



Tricks to success
Rule 1. The sweep may not self-intersect. A self-intersecting sweep is an invalid solid. Attempts to fuse it or cut it are very likely to fail. Nevertheless, this may be OK for 3d-printing and visualization purposes to leave the coil and the cylinder unfused (intersecting).

Rule 2. Remember that helix in FreeCAD is an imprecise thing. As a consequence, a cylinder made to mate with the thread precisely is very likely to fail to fuse to the thread. In general, avoid geometry coincident to elements of the sweep, such as tangent faces, edges tangent to faces they are not connected to, coincident and tangent edges, etc.

Tip 1. The radius of the helix does not matter (unless the helix is tapered). All that matters is the pitch and the height of the helix. This means that you can use a generic helix to generate a number of threads with equal pitch.

Tip 2. Keep it short (low number of turns). Long threads tend to fail in Boolean operations. Consider stacking the thread from short pieces using Draft Array, if a long thread proves problematic.

Pros and cons
+ Very natural way of defining thread profile

+ easy to understand

+ no problems with mesh generation, unlike method 3

- due to invalidity of self-intersecting sweeps, it is next to impossible to generate a gapless thread (that is, with no cylindrical faces at the outer or inner sides of the thread)

- Boolean operations are required to obtain meaningful results. These take long time and fail often.

- Threads with high number of turns are problematic.

Idea
The idea is to sweep a horizontal cross-section of the thread along the helix. The main problem here is that the relationship of thread profile and its horizontal cross-section is not trivial.



If one uses a circle as a horizontal profile (the circle has to be placed off the origin, that offset defines the depth of the thread), thread profile will be sinusoidal.

To obtain a standard sawtooth profile, a pair of mirrored archimedean spirals need to be fused into a wire. The resulting figure is a heart shape, which becomes barely distinguishable from a circle when the depth of the thread is small compared to its diameter (this is why such a "thick" thread is shown on the picture above).