Screw drives: Phillips, hex, Torx & Robertson recesses

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

Pure-Python port of BOSL2’s screw_drive.scad: masks for the driver recess cut into a screw head. The ScrewDrive class groups them as static methods that return a Bosl2Solid mask – subtract one from a head to make the recess:

head - ScrewDrive.phillips_mask("#2")     # a #2 Phillips recess
head - ScrewDrive.hex_drive_mask(5, 4)    # a 5mm hex (Allen) recess, 4mm deep
head - ScrewDrive.torx_mask(30, 4)        # a T30 Torx recess
head - ScrewDrive.robertson_mask(2)       # a #2 Robertson/square recess

Every *_mask is built bottom-on-the-XY-plane (BOSL2’s anchor=BOTTOM); pass center=True to center it vertically. The dimensional helpers – torx_info(), torx_diam(), torx_depth(), phillips_depth() and phillips_diam() – return the same numbers as their BOSL2 counterparts.

The dimension tables (Phillips ISO 4757, the Torx ISO 14583 OD/ID/depth/rounding table, and the Robertson square-drive inch table) are transcribed verbatim from screw_drive.scad and checked in tests/test_screw_drive.py.

Examples

A #2 Phillips recess cut into a tapered head:

from bosl2.screw_drive import ScrewDrive
(s3.cyl(diameter1=2, diameter2=8, height=4).down(2) - ScrewDrive.phillips_mask("#2")).show()

⬇ Download STL mesh

A T30 Torx tip:

from bosl2.screw_drive import ScrewDrive
ScrewDrive.torx_mask(size=30, length=10).show()

⬇ Download STL mesh

API reference

class bosl2.screw_drive.ScrewDrive[source]

Bases: object

Driver-recess masks and their dimensional helpers (BOSL2 screw_drive.scad).

Every *_mask method returns a Bosl2Solid positioned with its recess opening at the top and its bottom on the XY plane (BOSL2’s anchor=BOTTOM); subtract it from a screw head to cut the recess. Pass center=True to center the mask vertically instead.

static phillips_mask(size='#2', center=False, fn=None, fa=None, fs=None)[source]

A Phillips driver-recess mask for the given Phillips size (BOSL2 phillips_mask()).

Parameters:
  • size – bit size as "#0"..``”#4”`` or an integer 0..``4``.

  • center (bool) – center the mask vertically (default: bottom on the XY plane).

  • fn/fa/fs – facet controls for the revolved body (default: BOSL2’s fixed 36 facets).

  • fn (int | None)

  • fa (float | None)

  • fs (float | None)

Return type:

Bosl2Solid

Examples

A #2 Phillips recess cut into a tapered head:

from bosl2.screw_drive import ScrewDrive
(s3.cyl(diameter1=2, diameter2=8, height=4).down(2) - ScrewDrive.phillips_mask(size="#2")).show()

⬇ Download STL mesh

static phillips_depth(size, diameter)[source]

Recess depth needed to reach diameter diameter for a Phillips size, or None (BOSL2 phillips_depth()).

Parameters:

diameter (float)

static phillips_diam(size, depth)[source]

Recess diameter at the top when cut to depth for a Phillips size, or None (BOSL2 phillips_diam()).

Parameters:

depth (float)

static hex_drive_mask(size, length, slop=0.0, center=False)[source]

A hex (Allen) driver-recess mask, size across flats, length tall (BOSL2 hex_drive_mask()).

The recess is slightly oversized per the ISO standard; slop enlarges it by a further 2 * slop.

Parameters:
  • size (float)

  • length (float)

  • slop (float)

  • center (bool)

Return type:

Bosl2Solid

static torx_info(size)[source]

The TorxSpec (outer_diameter/inner_diameter/depth/tip_rounding/inner_rounding) for a Torx size (BOSL2 torx_info()).

Parameters:

size (int)

Return type:

TorxSpec

static torx_diam(size)[source]

Outer diameter of a Torx size profile (BOSL2 torx_diam()).

Parameters:

size (int)

Return type:

float

static torx_depth(size)[source]

Typical drive-hole depth for a Torx size (BOSL2 torx_depth()).

Parameters:

size (int)

Return type:

float

static torx_mask2d(size)[source]

The 2-D profile of a Torx size driver (BOSL2 torx_mask2d()).

Parameters:

size (int)

Return type:

Bosl2Solid

static torx_mask(size, length=5.0, center=False)[source]

A Torx driver-recess mask: the 2-D profile extruded length tall (BOSL2 torx_mask()).

Examples

A T30 Torx tip:

from bosl2.screw_drive import ScrewDrive
ScrewDrive.torx_mask(size=30, length=10).show()

⬇ Download STL mesh

Parameters:
  • size (int)

  • length (float)

  • center (bool)

Return type:

Bosl2Solid

static robertson_mask(size, extra=1.0, angle=2.5, slop=0.0)[source]

A Robertson/square driver-recess mask for square-drive size 0..``4`` (BOSL2 robertson_mask()).

Parameters:
  • size (int) – square-drive size, an integer 0..``4``.

  • extra (float) – extra length of drive mask beyond the nominal depth.

  • angle (float) – taper angle of each face (default 2.5, from BOSL2’s print tests).

  • slop (float) – enlarge the recess by 2 * slop.

Return type:

Bosl2Solid

Examples

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

phillips_mask

A #1 Phillips recess:

ScrewDrive.phillips_mask(size="#1").show()

⬇ Download STL mesh

A #2 Phillips recess:

ScrewDrive.phillips_mask(size="#2").show()

⬇ Download STL mesh

A #3 Phillips recess:

ScrewDrive.phillips_mask(size=3).show()

⬇ Download STL mesh

robertson_mask

A #2 Robertson (square) recess:

ScrewDrive.robertson_mask(size=2).show()

⬇ Download STL mesh