thread - parametric helical threads

Helical threads are very common in mechanical designs but can be tricky to create in a robust and efficient manner. This sub-package provides classes that create three common types of threads:

  • ISO Standard 60° threads found on most fasteners

  • Acme 29° threads found on imperial machine equipment

  • Metric Trapezoidal 30° thread found on metric machine equipment

In addition, all threads support four different end finishes:

  • “raw” - where the thread extends beyond the desired length ready for integration into another part

  • “fade” - where the end of the thread spirals in - or out for internal threads

  • “square” - where the end of the thread is flat

  • “chamfer” - where the end of the thread is chamfered as commonly found on machine screws

Here is what they look like (clockwise from the top: “fade”, “chamfer”, “square” and “raw”):

EndFinishes

When choosing between these four options, consider the performance differences between them. Here are some measurements that give a sense of the relative performance:

Finish

Time

“raw”

0.018s

“fade”

0.087s

“square”

0.370s

“chamfer”

1.641s

The “raw” and “fade” end finishes do not use any boolean operations which is why they are so fast. “square” does a cut() operation with a box while “chamfer” does an intersection() with a chamfered cylinder.

The following sections describe the different thread classes.

Thread

class Thread(apex_radius, apex_width, root_radius, root_width, pitch, length, apex_offset=0.0, hand='right', taper_angle=None, end_finishes=('raw', 'raw'), simple=False)

Helical thread

The most general thread class used to build all of the other threads. Creates right or left hand helical thread with the given root and apex radii.

Parameters
  • apex_radius (float) – Radius at the narrow tip of the thread.

  • apex_width (float) – Radius at the wide base of the thread.

  • root_radius (float) – Radius at the wide base of the thread.

  • root_width (float) – Thread base width.

  • pitch (float) – Length of 360° of thread rotation.

  • length (float) – End to end length of the thread.

  • apex_offset (float) – Asymmetric thread apex offset from center. Defaults to 0.0.

  • hand (Literal[‘right’, ‘left’]) – Twist direction. Defaults to “right”.

  • taper_angle (Optional[float]) – Cone angle for tapered thread. Defaults to None.

  • end_finishes (Tuple[Literal[‘raw’, ‘square’, ‘fade’, ‘chamfer’], Literal[‘raw’, ‘square’, ‘fade’, ‘chamfer’]]) –

    Profile of each end, one of:

    ”raw”

    unfinished which typically results in the thread extended below z=0 or above z=length

    ”fade”

    the thread height drops to zero over 90° of arc (or 1/4 pitch)

    ”square”

    clipped by the z=0 or z=length plane

    ”chamfer”

    conical ends which facilitates alignment of a bolt into a nut

    Defaults to (“raw”,”raw”).

  • simple (bool) – Stop at thread calculation, don’t create thread. Defaults to False.

Raises

ValueError – if end_finishes not in [“raw”, “square”, “fade”, “chamfer”]:

IsoThread

class IsoThread(major_diameter, pitch, length, external=True, hand='right', end_finishes=('fade', 'square'), simple=False)

ISO Standard Thread

Both external and internal ISO standard 60° threads as shown in the following diagram (from https://en.wikipedia.org/wiki/ISO_metric_screw_thread):

https://upload.wikimedia.org/wikipedia/commons/4/4b/ISO_and_UTS_Thread_Dimensions.svg

The following is an example of an internal thread with a chamfered end as might be found inside a nut:

_images/internal_iso_thread.png
Parameters
  • major_diameter (float) – Primary thread diameter

  • pitch (float) – Length of 360° of thread rotation

  • length (float) – End to end length of the thread

  • external (bool, optional) – External or internal thread selector. Defaults to True.

  • hand (Literal[, optional) – Twist direction. Defaults to “right”.

  • end_finishes (Tuple[ Literal[, optional) –

    Profile of each end, one of:

    ”raw”

    unfinished which typically results in the thread extended below z=0 or above z=length

    ”fade”

    the thread height drops to zero over 90° of arc (or 1/4 pitch)

    ”square”

    clipped by the z=0 or z=length plane

    ”chamfer”

    conical ends which facilitates alignment of a bolt into a nut

    Defaults to (“fade”, “square”).

  • simple (bool) – Stop at thread calculation, don’t create thread. Defaults to False.

Variables
  • thread_angle (int) – 60 degrees

  • h_parameter (float) – Value of h as shown in the thread diagram

  • min_radius (float) – Inside radius of the thread diagram

Raises
  • ValueError – if hand not in [“right”, “left”]:

  • ValueError – end_finishes not in [“raw”, “square”, “fade”, “chamfer”]

AcmeThread

class AcmeThread(size, length, external=True, hand='right', end_finishes=('fade', 'fade'))

ACME Thread

The original trapezoidal thread form, and still probably the one most commonly encountered worldwide, with a 29° thread angle, is the Acme thread form.

The following is the acme thread with faded ends:

_images/acme_thread.png
Parameters
  • size (str) – size as a string (i.e. “3/4” or “1 1/4”)

  • length (float) – thread length

  • external (bool, optional) – external or internal thread selector. Defaults to True.

  • hand (Literal[, optional) – twist direction. Defaults to “right”.

  • end_finishes (Tuple[ Literal[, optional) –

    Profile of each end, one of:

    ”raw”

    unfinished which typically results in the thread extended below z=0 or above z=length

    ”fade”

    the thread height drops to zero over 90° of arc (or 1/4 pitch)

    ”square”

    clipped by the z=0 or z=length plane

    ”chamfer”

    conical ends which facilitates alignment of a bolt into a nut

    Defaults to (“fade”, “fade”).

Raises
  • ValueError – hand must be one of “right” or “left”

  • ValueError – end_finishes invalid, must be tuple() of “raw, square, taper, or chamfer”

Variables
  • thread_angle (int) – thread angle in degrees

  • diameter (float) – thread diameter

  • pitch (float) – thread pitch

MetricTrapezoidalThread

class MetricTrapezoidalThread(size, length, external=True, hand='right', end_finishes=('fade', 'fade'))

Metric Trapezoidal Thread

The ISO 2904 standard metric trapezoidal thread with a thread angle of 30°

Parameters
  • size (str) – specified as a sting with diameter x pitch in mm (i.e. “8x1.5”)

  • length (float) – End to end length of the thread

  • external (bool, optional) – external or internal thread selector. Defaults to True.

  • hand (Literal[, optional) – twist direction. Defaults to “right”.

  • end_finishes (Tuple[ Literal[, optional) –

    Profile of each end, one of:

    ”raw”

    unfinished which typically results in the thread extended below z=0 or above z=length

    ”fade”

    the thread height drops to zero over 90° of arc (or 1/4 pitch)

    ”square”

    clipped by the z=0 or z=length plane

    ”chamfer”

    conical ends which facilitates alignment of a bolt into a nut

    Defaults to (“fade”, “fade”).

Raises
  • ValueError – hand must be one of “right” or “left”

  • ValueError – end_finishes invalid, must be tuple() of “raw, square, taper, or chamfer”

Variables
  • thread_angle (int) – thread angle in degrees

  • diameter (float) – thread diameter

  • pitch (float) – thread pitch

TrapezoidalThread

The base class of the AcmeThread and MetricTrapezoidalThread classes.

class TrapezoidalThread(size, length, external=True, hand='right', end_finishes=('fade', 'fade'))

Trapezoidal Thread Base Class

Trapezoidal Thread base class for Metric and Acme derived classes

Trapezoidal thread forms are screw thread profiles with trapezoidal outlines. They are the most common forms used for leadscrews (power screws). They offer high strength and ease of manufacture. They are typically found where large loads are required, as in a vise or the leadscrew of a lathe.

Parameters
  • size (str) – specified by derived class

  • length (float) – thread length

  • external (bool, optional) – external or internal thread selector. Defaults to True.

  • hand (Literal[, optional) – twist direction. Defaults to “right”.

  • end_finishes (Tuple[ Literal[, optional) –

    Profile of each end, one of:

    ”raw”

    unfinished which typically results in the thread extended below z=0 or above z=length

    ”fade”

    the thread height drops to zero over 90° of arc (or 1/4 pitch)

    ”square”

    clipped by the z=0 or z=length plane

    ”chamfer”

    conical ends which facilitates alignment of a bolt into a nut

    Defaults to (“fade”, “fade”).

Raises
  • ValueError – hand must be one of “right” or “left”

  • ValueError – end_finishes invalid, must be tuple() of “raw, square, taper, or chamfer”

Variables
  • thread_angle (int) – thread angle in degrees

  • diameter (float) – thread diameter

  • pitch (float) – thread pitch

PlasticBottleThread

class PlasticBottleThread(size, external=True, hand='right', manufacturingCompensation=0.0)

ASTM D2911 Plastic Bottle Thread

The ASTM D2911 Standard Plastic Bottle Thread.

L Style:

All-Purpose Thread - trapezoidal shape with 30° shoulders, metal or platsic closures

M Style:

Modified Buttress Thread - asymmetric shape with 10° and 40/45/50° shoulders, plastic closures

_images/plasticThread.png
Parameters
  • size (str) – as defined by the ASTM is specified as [L|M][diameter(mm)]SP[100|103|110|200|400|410|415|425|444]

  • external (bool, optional) – external or internal thread selector. Defaults to True.

  • hand (Literal[, optional) – twist direction. Defaults to “right”.

  • manufacturingCompensation (float, optional) – used to compensate for over-extrusion of 3D printers. A value of 0.2mm will reduce the radius of an external thread by 0.2mm (and increase the radius of an internal thread) such that the resulting 3D printed part matches the target dimensions. Defaults to 0.0.

Raises
  • ValueError – hand must be one of “right” or “left”

  • ValueError – size invalid, must match [L|M][diameter(mm)]SP[100|103|110|200|400|410|415:425|444]

  • ValueError – finish invalid

  • ValueError – diameter invalid

Example

thread = PlasticBottleThread(
    size="M38SP444", external=False, manufacturingCompensation=0.2 * MM
)