# Threads

> Life and death are one thread, the same line viewed from different sides.

— Lao Tzu

| This page is still under 'heavy construction', but the routines in The GHOUL do work as advertised.

## Threads

Try not to die.

Making metric bolts with a 3D printer is a bit silly, but it’s great to make caps, closures and adapters to up-cycle beverage containers an so on. Be very careful if you’re thinking about making threads for pressure applications like garden hoses and, yep, also carbonated beverages.

Do you know how much force there is on a (closed) garden hose cross section? It can easily be up to 40 pounds. That’s a serious punch in the face. Please don’t rely on 3D printed products to support (substantial) weight, or other (large) forces.

If you cohabit with pets or kids, please consider their safety.

There’s a reason (beyond litigation and culpability) why consumer products are tested.

The GHOUL has an excellent `Thread()` module that makes threads like no other you’ve seen. I promise. It’s very versatile, and allows you to make threads of any cross-section that can be tapered and/or interrupted. `Thread()` uses the `SVG()` library to generate thread-profiles with proper root-radii; this reduces the stress risers created by the flat, or even sharp angular roots seen in many other thread libraries, and thus makes stronger threads. Supporting surfaces can be generated simultaneously, and it’s easy to make a `difference()` plug for internal threads for through- or blind holes. It also generates a very nice Higbee cut with several options. The only downside of such a versatile routine is of course that, with so many options, it’s very information-hungry; at first sight the number of parameters can be a bit overwhelming, but don’t despair, most calls can be as simple as this one: `Thread("MetricThread",10,20);` for M10 external thread, 20 millimetres long.

If you’d like a nice 45° chamfer at the end like in my image here; `Thread()` publishes the support surface as an OpenSCAD `cylinder()` call in the console, just grab it from there and generate a truncated cone for a chamfer on the end of the threads, because `Thread()` makes great threads, but that’s all folks.

It doesn’t chew your food and make your coffee. If you want a bolt, or a nut or whatever, you’re responsible for generating the appropriate shanks or object to `difference()` cut the internal threads from. If you’re in a rush for a bolt or nut, use `SimpleThread()`, it does those things at the cost of simplicity and limited control.

| The following text contains some terms that you may not be familiar with. This documentation documents The GHOUL, it’s no formal engineering course. If you’re not familiar with threads and their terminology, please start with this Wikipedia page and take it from there. I’ve assumed a basic understanding. If you don’t know the difference between 'Lead' and 'Pitch', or worse, you think they’re the same thing: Please leave, and get informed first.

`Thread()` uses a 'sub-library' if you will: TheGHOUL/Lib/Parts/ThreadData.scad contains the routines that generate the thread-helix cross sections (profiles) and lookup lists of pitch, minor and major diameter &c. for the most common standard threads and some not so common ones. Their documentation follows after the documentation for `Thread()`.

### `Thread()`

`Thread(ThreadType, NominalDiameter, Length, External=true, Turns, Pitch, Lead, ThreadAngle, Height, TaperAngle, LeftHanded=false, MultiStart=1, HigbeeIn=30, HigbeeOut=0, Higbee2D=false, HigbeeSkew=0, RootClearance, Clearance=0, FlankContact=0, Interrupted=[false,0,0,0], ConversionFactor=1, Support=false, FN=12, _Quiet=false, ItemReference="")`

- ThreadType, string, identifier of the desired thread profile. Thread profiles are all described in TheGHOUL/Lib/Parts/ThreadData.scad, which also contains the lookup tables for standardised threads.

- NominalDiameter, scalar or string, the nominal diameter or a diameter identifier of the external threads, like '#4'. It is the same for external and internal threads, for standardised threads, this is an identifier, not necessarily an actual dimension. For non-standard threads, it is the O/D of the external threads.

- Length, scalar, desired length of the thread.

- External, Boolean, true for external thread.

- HigbeeIn, HigbeeOut, scalars, degrees of turn over which to apply run-in and/or -out, very similar to a Higbee cut. Default, is HigbeeIn=30, HigbeeOut=0,

- Higbee2D. Boolean, the Higbee cut will be '2D', i.e, in the radial as well as the axial direction, just try it out.

- HigbeeSkew, scalar, [0:1], the Higbee cut will be skewed towards the end of the thread for even better engagement, only works when Higbee2D=true.

- Turns, scalar, total number of turns of the thread, includes run-in and -out. If both Length and Turns are specified, Turns takes prevalence.

- Pitch, scalar, width of a single thread, also axial travel per turn of a standard single thread. (Standard here means that the lead is equal to a single pitch; if you don’t know the difference between lead and pitch: please read the note in the intro. GTS.)

- Lead, scalar, the axial distance travelled by a single thread through one full rotation. Normally equal to Pitch, but often larger in food-closure threads or quick-connects.

- ThreadAngle, scalar, included angle between thread profile flanks.

- Height, scalar, full height of thread profile.

- TaperAngle, scalar, included taper angle of the thread.

- LeftHanded, Boolean, true for left-handed threads.

- MultiStart, scalar, multiple thread helixes, like in many food container closures.

- RootClearance, scalar, clearance at the root of non-standard threads like 'SquareThread'. This does not apply to standard threads as theirs is calculated by the profile generator in the ThreadData.scad library. Positive is less material is more clearance.

- Clearance, scalar, an absolute value in the design’s NATIVE UNITS, not affected by ConversionFactor. A change in thread size, usually postive in order to provide more actual (positive) clearance, flank contact correction (see below) is available for this.

  - This is applied to the thread AND root-radius of "standard" threads, but NOT to the 'roots' of square threads and such, which have RootClearance for that.

  - Negative Clearance increases the profile in radial and axial direction and may (read: probably will) cause interference.

  - There is also a built in, production equipment (your 3D printer) dependent, clearance called ThreadAllowance, it is set in TheGHOUL/Lib/Definitions/Constants.scad. A notice is given at run-time if ThreadAllowance is 0.

- FlankContact, switch, rotate the finished thread polyhedron to preserve contact or maintain the lock-up point with the mating threads when additional Clearance has been applied.

  - 0 : No preservation.

  - -1 : CCW direction contact preservation.

  - 1 : CW direction contact preservation.

- Interrupted, array, interrupted thread parameter array consisting of:

  - [
    Flag, Boolean, true for Interrupted threads.
    ThreadAngle,
    GapAngle,
    HigbeeAngle
    ]

- ConversionFactor, scalar, thread profiles are written with 'implicit units', i.e. a 1/2" UNC thread has a major diameter of 0.5, not '12.7 mm' so when you’re designing in mm and you want to use a UNC bolt, you must specify a ConversionFactor of 25.4 or your thread will have an OD of 0.5 mm.

- Support, Boolean, generate the support surface for the thread. This generates a simply cylinder inside the external threads, however, for internal threads, a negative 'cutting body' is created which can then be `difference()`d from an object.

- FN, scalar, defaults to 12, the number of line segments used to approximate a full circle arc in the generated thread profiles, just like $fn; it must be a multiple of 4. `SVG_A()` is used to generate the arcs such as root radii &c. FN is passed to `SVG_A()` and it’s value is assigned to $fn inside it’s variable scope, to reduce the resolution of arc segments from TheGHOUL’s default $fn value of 100. Keep FN reasonably low, 12 to 24 give very satisfactory root radii, larger values very quickly result in overly complex meshes and long rendering times.

- ItemReference, string, `Thread()` publishes the dimensions of the support surface for each thread it generates to the console. The user can use ItemReference to make it easier to identify the correct support surface to use.

Many threads share a common shape, know as 'profile' or cross-section. The common UNC and UNF threads and ISO threads share the same profile, only nominal diameters and pitch are different. Standardised threads like these are defined in TheGHOUL/Lib/Parts/ThreadData.scad, including lookup tables with their nominal diameters and pitch.

ThreadData.scad also contains definitions of a few specialised thread types, such as square- and knuckle-thread.