Threading: screw threads, rods & nuts¶
⚙️ Spec sheet → — visual schematic and metrics measured from a real rendered STL.
⚙️ Parts catalog → — this module is featured in the visual parts catalog.
Pure-Python port of the core of BOSL2’s threading.scad. The
ThreadedRod and
ThreadedNut classes build 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.)
Convenience functions return pre-configured rods and nuts:
iso_threaded_rod(12, 24, 1.75) # ISO M12 x 1.75
acme_threaded_rod(20, 30, 4) # 29-degree ACME
iso_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:
from pybosl2.parts.threading import iso_threaded_rod
iso_threaded_rod(16, 30, 2, fa=4, fs=1).show()
An ACME lead screw:
from pybosl2.parts.threading import acme_threaded_rod
acme_threaded_rod(24, 36, 5, fa=4, fs=1).show()
A rod threaded into its matching hex nut (shown side by side):
from pybosl2.parts.threading import iso_threaded_rod, iso_threaded_nut
rod = iso_threaded_rod(12, 30, 1.75, fa=6, fs=1).shape()
nut = iso_threaded_nut(18, 12, 10, 1.75, slop=0.1, fa=6, fs=1).shape().right(22)
(rod | nut).show()
API reference¶
-
class pybosl2.parts.threading.ThreadedRod(d, l, pitch, profile, starts=
1, left_handed=False, fn=None, fa=None, fs=None)[source]¶ Bases:
objectA threaded rod built from an explicit 2-D thread profile.
profile is a
ThreadProfileor a plain point list in pitch units (x in [-1/2, 1/2], y the depth fraction). starts is the number of thread starts and left_handed flips the helix.Examples
An M20×2.5 ISO threaded rod, 30 mm long:
from pybosl2.parts.threading import ThreadedRod, iso_threaded_rod iso_threaded_rod(d=20, l=30, pitch=2.5, fa=6, fs=1).show()Loading 3-D preview…- Parameters:¶
- property diameter : float¶
Nominal outer diameter in mm.
- property length : float¶
Length in mm.
- property pitch : float¶
Thread pitch in mm.
- property starts : int¶
Number of thread starts.
- property left_handed : bool¶
True for left-handed threads.
-
class pybosl2.parts.threading.ThreadedNut(nutwidth, id, h, pitch, profile, shape=
NutShape.HEX, starts=1, left_handed=False, slop=0.0, fn=None, fa=None, fs=None)[source]¶ Bases:
objectA nut: a hex or square body with a threaded hole cut by a matching thread tap.
Examples
An M8 nut for an M8×1.25 rod:
from pybosl2.parts.threading import ThreadedNut, iso_threaded_nut iso_threaded_nut(nutwidth=13, id=8, h=6.8, pitch=1.25).show()Loading 3-D preview…- Parameters:¶
- property nutwidth : float¶
Across-flats width in mm.
- property inner_diameter : float¶
Inner (threaded) diameter in mm.
- property height : float¶
Nut thickness in mm.
- property pitch : float¶
Thread pitch in mm.
- property nut_shape : NutShape¶
Nut outer shape.
- property starts : int¶
Number of thread starts.
- property left_handed : bool¶
True for left-handed threads.
-
class pybosl2.parts.threading.ThreadHelix(d, pitch, thread_depth=
None, flank_angle=15, turns=1, starts=1, left_handed=False, profile=None)[source]¶ Bases:
objectA single helical thread ridge, for adding threads onto your own cylinder.
The thread crest is at diameter d; give thread_depth and flank_angle, or an explicit profile. Built entirely through spiral_sweep (VNF output), so it does not accept fn/fa/fs smoothing parameters.
Examples
A trapezoidal thread helix around a cylinder:
from pybosl2.shapes3d import cylinder as cyl from pybosl2.parts.threading import ThreadHelix (cyl(diameter=20, height=30) | ThreadHelix(d=20, pitch=5, turns=6).shape()).show()Loading 3-D preview…- Parameters:¶
- property diameter : float¶
Crest diameter in mm.
- property pitch : float¶
Thread pitch in mm.
- property turns : float¶
Number of turns.
- property starts : int¶
Number of thread starts.
- property left_handed : bool¶
True for left-handed threads.
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:
from pybosl2.parts.threading import iso_threaded_rod
iso_threaded_rod(d=25, l=20, pitch=2).show()
Left-handed:
from pybosl2.parts.threading import iso_threaded_rod
iso_threaded_rod(d=10, l=20, pitch=1.25, left_handed=True).show()
threaded_nut
A hex nut:
from pybosl2.parts.threading import iso_threaded_nut
iso_threaded_nut(nutwidth=16, id=8, h=8, pitch=1.25).show()
trapezoidal_threaded_rod
A trapezoidal-thread rod:
from pybosl2.parts.threading import trapezoidal_threaded_rod
trapezoidal_threaded_rod(d=10, l=40, pitch=2).show()
trapezoidal_threaded_nut
Its nut:
from pybosl2.parts.threading import trapezoidal_threaded_nut
trapezoidal_threaded_nut(nutwidth=16, id=8, h=8, pitch=2).show()
acme_threaded_rod
An Acme lead screw:
from pybosl2.parts.threading import acme_threaded_rod
acme_threaded_rod(d=10, l=30, pitch=2, starts=3).show()
acme_threaded_nut
An Acme nut:
from pybosl2.parts.threading import acme_threaded_nut
acme_threaded_nut(nutwidth=16, id=10, h=10, pitch=2).show()
buttress_threaded_rod
A buttress-thread rod:
from pybosl2.parts.threading import buttress_threaded_rod
buttress_threaded_rod(d=10, l=20, pitch=1.25).show()
buttress_threaded_nut
Its nut:
from pybosl2.parts.threading import buttress_threaded_nut
buttress_threaded_nut(nutwidth=16, id=8, h=8, pitch=1.25).show()
square_threaded_rod
A square-thread rod:
from pybosl2.parts.threading import square_threaded_rod
square_threaded_rod(d=10, l=20, pitch=2, starts=2).show()
square_threaded_nut
Its nut:
from pybosl2.parts.threading import square_threaded_nut
square_threaded_nut(nutwidth=16, id=10, h=10, pitch=2, starts=2).show()
thread_helix
A single thread ridge, swept as a helix:
from pybosl2.parts.threading import ThreadHelix
ThreadHelix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2.5).show()