Threading: screw threads, rods & nuts

⚙️ Parts catalog →  —  this module is featured in the visual parts catalog.

Pure-Python port of the core of BOSL2’s threading.scad. The Threading class builds screw threads by generating the whole rod (core + helical thread) as one manifold polyhedron – an angular sweep of the thread profile stacked over every turn – so the result is always watertight. (Sweeping the thread and CSG-unioning a coaxial core instead is what Manifold cannot triangulate cleanly, so this port builds the polyhedron directly, as BOSL2 does.)

Every method is a class method returning a Bosl2Solid:

Threading.threaded_rod(12, 24, 1.75)                 # ISO M12 x 1.75
Threading.acme_threaded_rod(20, 30, 4)               # 29-degree ACME
Threading.threaded_nut(18, 12, 10, 1.75, slop=0.1)   # matching hex nut

A rod is a threaded cylinder; a nut is a hex/square block with a matching threaded hole (cut by a thread “tap”, with slop radial clearance). pitch is the axial distance between threads, starts the number of thread starts, and left_handed flips the helix. The thread profiles are ported verbatim from BOSL2 (checked in tests/test_threading.py), and the geometry is verified watertight with the correct major/minor diameter and length.

Coverage of BOSL2 threading.scad

BOSL2 function

Status

Notes

generic_threaded_rod / generic_threaded_nut

ported

the profile-driven core every other builder uses.

threaded_rod / threaded_nut

ported

ISO (metric) / UTS 60-degree triangular threads.

trapezoidal_threaded_rod / trapezoidal_threaded_nut

ported

symmetric trapezoidal (metric trapezoidal by default; thread_angle / thread_depth).

acme_threaded_rod / acme_threaded_nut

ported

29-degree ACME threads.

square_threaded_rod / square_threaded_nut

ported

square-profile threads.

buttress_threaded_rod / buttress_threaded_nut

ported

asymmetric buttress threads.

thread_helix

ported

a single helical thread ridge, to add onto your own cylinder.

blunt-start / lead-in tapers, teardrop, bevels

not ported

the BOSL2 end-refinements; this port cuts the ends flush. A follow-up.

ball_screw_rod / npt_threaded_rod / bspp_threaded_rod

not ported

specialised thread forms; a follow-up.

Examples

An ISO M16 x 2 rod:

Threading.threaded_rod(16, 30, 2, _fa=4, _fs=1).show()

⬇ Download STL mesh

An ACME lead screw:

Threading.acme_threaded_rod(24, 36, 5, _fa=4, _fs=1).show()

⬇ Download STL mesh

A rod threaded into its matching hex nut (shown side by side):

rod = Threading.threaded_rod(12, 30, 1.75, _fa=6, _fs=1)
nut = Threading.threaded_nut(18, 12, 10, 1.75, slop=0.1, _fa=6, _fs=1).right(22)
(rod | nut).show()

⬇ Download STL mesh

API reference

class bosl2.threading.Threading[source]

Bases: object

Screw-thread generators (BOSL2 threading.scad). Every method returns a Bosl2Solid; call them on the class, e.g. Threading.threaded_rod(...).

A rod is a threaded cylinder; a nut is a hex/square block with a matching threaded hole (cut by a thread ‘tap’, with slop clearance). pitch is the axial distance between threads, starts the number of thread starts, and left_handed flips the helix.

static generic_threaded_rod(d, length, pitch, profile, starts=1, left_handed=False, fn=None, fa=None, fs=None)[source]

A threaded rod from an explicit 2-D thread profile (x in [-1/2, 1/2], y the depth fraction, both in pitch units) – the core every other rod builds on (BOSL2 generic_threaded_rod()).

Parameters:
  • d (float)

  • length (float)

  • pitch (float)

  • starts (int)

  • left_handed (bool)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static generic_threaded_nut(nutwidth, inner_diameter, h, pitch, profile, shape='hex', starts=1, left_handed=False, slop=0.0, fn=None, fa=None, fs=None)[source]

A nut from an explicit thread profile (BOSL2 generic_threaded_nut()).

Parameters:
  • nutwidth (float)

  • inner_diameter (float)

  • h (float)

  • pitch (float)

  • starts (int)

  • left_handed (bool)

  • slop (float)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static threaded_rod(d, length, pitch, starts=1, left_handed=False, fn=None, fa=None, fs=None)[source]

An ISO (metric) / UTS (imperial) 60-degree triangular threaded rod (BOSL2 threaded_rod()).

Parameters:
  • d (float)

  • length (float)

  • pitch (float)

  • starts (int)

  • left_handed (bool)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static threaded_nut(nutwidth, inner_diameter, h, pitch, shape='hex', starts=1, left_handed=False, slop=0.0, fn=None, fa=None, fs=None)[source]

A hex/square nut for an ISO/UTS threaded rod (BOSL2 threaded_nut()).

Parameters:
  • nutwidth (float)

  • inner_diameter (float)

  • h (float)

  • pitch (float)

  • starts (int)

  • left_handed (bool)

  • slop (float)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static trapezoidal_threaded_rod(d, length, pitch, thread_angle=30, thread_depth=None, starts=1, left_handed=False, fn=None, fa=None, fs=None)[source]

A symmetric trapezoidal threaded rod (metric trapezoidal by default) (BOSL2 trapezoidal_threaded_rod()).

Parameters:
  • d (float)

  • length (float)

  • pitch (float)

  • thread_angle (float)

  • thread_depth (float | None)

  • starts (int)

  • left_handed (bool)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static trapezoidal_threaded_nut(nutwidth, inner_diameter, h, pitch, thread_angle=30, thread_depth=None, shape='hex', starts=1, left_handed=False, slop=0.0, fn=None, fa=None, fs=None)[source]

A nut for a trapezoidal threaded rod (BOSL2 trapezoidal_threaded_nut()).

Parameters:
  • nutwidth (float)

  • inner_diameter (float)

  • h (float)

  • pitch (float)

  • thread_angle (float)

  • thread_depth (float | None)

  • starts (int)

  • left_handed (bool)

  • slop (float)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static acme_threaded_rod(d, length, pitch, thread_depth=None, starts=1, left_handed=False, fn=None, fa=None, fs=None)[source]

A 29-degree ACME threaded rod (BOSL2 acme_threaded_rod()).

Parameters:
  • d (float)

  • length (float)

  • pitch (float)

  • thread_depth (float | None)

  • starts (int)

  • left_handed (bool)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static acme_threaded_nut(nutwidth, inner_diameter, h, pitch, thread_depth=None, shape='hex', starts=1, left_handed=False, slop=0.0, fn=None, fa=None, fs=None)[source]

A nut for an ACME threaded rod (BOSL2 acme_threaded_nut()).

Parameters:
  • nutwidth (float)

  • inner_diameter (float)

  • h (float)

  • pitch (float)

  • thread_depth (float | None)

  • starts (int)

  • left_handed (bool)

  • slop (float)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static square_threaded_rod(d, length, pitch, starts=1, left_handed=False, fn=None, fa=None, fs=None)[source]

A square-profile threaded rod (BOSL2 square_threaded_rod()).

Parameters:
  • d (float)

  • length (float)

  • pitch (float)

  • starts (int)

  • left_handed (bool)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static square_threaded_nut(nutwidth, inner_diameter, h, pitch, shape='hex', starts=1, left_handed=False, slop=0.0, fn=None, fa=None, fs=None)[source]

A nut for a square threaded rod (BOSL2 square_threaded_nut()).

Parameters:
  • nutwidth (float)

  • inner_diameter (float)

  • h (float)

  • pitch (float)

  • starts (int)

  • left_handed (bool)

  • slop (float)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static buttress_threaded_rod(d, length, pitch, starts=1, left_handed=False, fn=None, fa=None, fs=None)[source]

An asymmetric buttress threaded rod (BOSL2 buttress_threaded_rod()).

Parameters:
  • d (float)

  • length (float)

  • pitch (float)

  • starts (int)

  • left_handed (bool)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static buttress_threaded_nut(nutwidth, inner_diameter, h, pitch, shape='hex', starts=1, left_handed=False, slop=0.0, fn=None, fa=None, fs=None)[source]

A nut for a buttress threaded rod (BOSL2 buttress_threaded_nut()).

Parameters:
  • nutwidth (float)

  • inner_diameter (float)

  • h (float)

  • pitch (float)

  • starts (int)

  • left_handed (bool)

  • slop (float)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

static thread_helix(d, pitch, thread_depth=None, flank_angle=15, turns=1, starts=1, left_handed=False, profile=None, fn=None, fa=None, fs=None)[source]

A single helical thread ridge (no core), for adding threads onto your own cylinder (BOSL2 thread_helix()). The thread crest is at diameter d; give thread_depth and flank_angle, or an explicit profile.

Parameters:
  • d (float)

  • pitch (float)

  • thread_depth (float | None)

  • flank_angle (float)

  • turns (float)

  • starts (int)

  • left_handed (bool)

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

Examples

These mirror the examples in BOSL2’s threading.scad, rendered live through PythonSCAD. Examples that rely on BOSL2’s attachment/anchor system, or on features not in this port, are omitted.

threaded_rod

An ISO/UTS threaded rod:

Threading.threaded_rod(diameter=25, length=20, pitch=2).show()
_images/add3f2e2dda328b3.png

Left-handed:

Threading.threaded_rod(diameter=10, length=20, pitch=1.25, left_handed=True).show()
_images/3e0b5c8f69494aa2.png

threaded_nut

A hex nut:

Threading.threaded_nut(nutwidth=16, inner_diameter=8, height=8, pitch=1.25).show()
_images/078364ee6b96231a.png

trapezoidal_threaded_rod

A trapezoidal-thread rod:

Threading.trapezoidal_threaded_rod(diameter=10, length=40, pitch=2).show()
_images/cf150ab390d0b39d.png

trapezoidal_threaded_nut

Its nut:

Threading.trapezoidal_threaded_nut(nutwidth=16, inner_diameter=8, height=8, pitch=2).show()
_images/c9289f4ed8bd1164.png

acme_threaded_rod

An Acme lead screw:

Threading.acme_threaded_rod(diameter=10, length=30, pitch=2, starts=3).show()
_images/1c160d8b47d0ae5b.png

acme_threaded_nut

An Acme nut:

Threading.acme_threaded_nut(nutwidth=16, inner_diameter=10, height=10, pitch=2).show()
_images/8ad34e4ea3e6126f.png

buttress_threaded_rod

A buttress-thread rod:

Threading.buttress_threaded_rod(diameter=10, length=20, pitch=1.25).show()
_images/794fa654528bf199.png

buttress_threaded_nut

Its nut:

Threading.buttress_threaded_nut(nutwidth=16, inner_diameter=8, height=8, pitch=1.25).show()
_images/860b24ac95e0d539.png

square_threaded_rod

A square-thread rod:

Threading.square_threaded_rod(diameter=10, length=20, pitch=2, starts=2).show()
_images/2720ce07b9be79e9.png

square_threaded_nut

Its nut:

Threading.square_threaded_nut(nutwidth=16, inner_diameter=10, height=10, pitch=2, starts=2).show()
_images/f49a28a8ce80e99d.png

thread_helix

A single thread ridge, swept as a helix:

Threading.thread_helix(diameter=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2.5).show()
_images/0476e1b744ef8945.png