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 |
|---|---|---|
|
ported |
the profile-driven core every other builder uses. |
|
ported |
ISO (metric) / UTS 60-degree triangular threads. |
|
ported |
symmetric trapezoidal (metric trapezoidal by default; |
|
ported |
29-degree ACME threads. |
|
ported |
square-profile threads. |
|
ported |
asymmetric buttress threads. |
|
ported |
a single helical thread ridge, to add onto your own cylinder. |
blunt-start / lead-in tapers, |
not ported |
the BOSL2 end-refinements; this port cuts the ends flush. A follow-up. |
|
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()
An ACME lead screw:
Threading.acme_threaded_rod(24, 36, 5, _fa=4, _fs=1).show()
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()
API reference¶
- class bosl2.threading.Threading[source]¶
Bases:
objectScrew-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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
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()
Left-handed:
Threading.threaded_rod(diameter=10, length=20, pitch=1.25, left_handed=True).show()
threaded_nut
A hex nut:
Threading.threaded_nut(nutwidth=16, inner_diameter=8, height=8, pitch=1.25).show()
trapezoidal_threaded_rod
A trapezoidal-thread rod:
Threading.trapezoidal_threaded_rod(diameter=10, length=40, pitch=2).show()
trapezoidal_threaded_nut
Its nut:
Threading.trapezoidal_threaded_nut(nutwidth=16, inner_diameter=8, height=8, pitch=2).show()
acme_threaded_rod
An Acme lead screw:
Threading.acme_threaded_rod(diameter=10, length=30, pitch=2, starts=3).show()
acme_threaded_nut
An Acme nut:
Threading.acme_threaded_nut(nutwidth=16, inner_diameter=10, height=10, pitch=2).show()
buttress_threaded_rod
A buttress-thread rod:
Threading.buttress_threaded_rod(diameter=10, length=20, pitch=1.25).show()
buttress_threaded_nut
Its nut:
Threading.buttress_threaded_nut(nutwidth=16, inner_diameter=8, height=8, pitch=1.25).show()
square_threaded_rod
A square-thread rod:
Threading.square_threaded_rod(diameter=10, length=20, pitch=2, starts=2).show()
square_threaded_nut
Its nut:
Threading.square_threaded_nut(nutwidth=16, inner_diameter=10, height=10, pitch=2, starts=2).show()
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()