Screw drives: Phillips, hex, Torx & Robertson recesses

⚙️ 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 BOSL2’s screw_drive.scad: masks for the driver recess cut into a screw head. The pybosl2.parts.screw_drive module provides classes and functions that each return a shapes3d mask – subtract one from a head to make the recess:

head - PhillipsMask("#2").shape()     # a #2 Phillips recess
head - HexDriveMask(5, 4).shape()     # a 5mm hex (Allen) recess, 4mm deep
head - TorxMask(30, 4).shape()        # a T30 Torx recess
head - RobertsonMask(2).shape()       # 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 spec classes TorxSpec and PhillipsSpec return the same dimensional data 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 pybosl2 import shapes3d as s3
from pybosl2.parts.screw_drive import PhillipsMask

(s3.cyl(diameter1=2, diameter2=8, height=4).down(2) - PhillipsMask("#2").shape()).show()
Loading 3-D preview…

⬇ Download STL mesh

A T30 Torx tip:

from pybosl2.parts.screw_drive import TorxMask
TorxMask(size=30, l=10).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

API reference

class pybosl2.parts.screw_drive.PhillipsMask(size='#2', center=False, fn=None, fa=None, fs=None, l=None)[source]

Bases: object

Phillips driver-recess mask for a given bit size (BOSL2 phillips_mask()).

The mask is positioned with its opening at the top and its bottom on the XY plane (BOSL2’s anchor=BOTTOM). Pass center=True to center the mask vertically instead.

Examples

A #2 Phillips recess cut into a tapered head:

from pybosl2.parts.screw_drive import PhillipsMask
from pybosl2.solid import cyl
(cyl(diameter1=2, diameter2=8, height=4).down(2) - PhillipsMask(size="#2").shape()).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
size : str | int

center : bool

fn : int | None

fa : float | None

fs : float | None

l : float | None

property size : str | int

Phillips bit size.

property center : bool

Whether the mask is centered vertically.

property fn : int | None

Facet count override.

property fa : float | None

Minimum facet angle.

property fs : float | None

Minimum facet size.

property l : float | None

Overall length of the recess.

property shaft : float

Shaft/outer diameter.

property length : float

Computed height of the recess.

shape()[source]

Return the Phillips driver-recess mask geometry.

Examples

Generate an STL of a #2 Phillips recess:

from pybosl2.parts.screw_drive import PhillipsMask
PhillipsMask(size="#2").shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Return type:

CsgSolid

show()[source]

Display the Phillips driver-recess mask in the viewer.

Return type:

None

class pybosl2.parts.screw_drive.HexDriveMask(size, l, slop=0.0, center=False)[source]

Bases: object

Hex (Allen) driver-recess mask (BOSL2 hex_drive_mask()).

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

Examples

A 2.5 mm hex drive mask, 5 mm deep:

from pybosl2.parts.screw_drive import HexDriveMask
HexDriveMask(size=2.5, l=5).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
size : float

l : float

slop : float

center : bool

property size : float

Across flats dimension.

property l : float

Height of the recess.

property slop : float

Slop enlargement.

property center : bool

Whether the mask is centered vertically.

property realsize : float

Actual across-flats dimension after ISO oversizing.

shape()[source]

Return the hex drive mask geometry.

Return type:

CsgSolid

show()[source]

Display the hex drive mask in the viewer.

Return type:

None

class pybosl2.parts.screw_drive.TorxMask(size, l=5.0, center=False)[source]

Bases: object

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

Examples

A T30 Torx tip:

from pybosl2.parts.screw_drive import TorxMask
TorxMask(size=30, l=10).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
size : int

l : float

center : bool

property size : int

Torx size number.

property l : float

Height of the recess.

property center : bool

Whether the mask is centered vertically.

property outer_diameter : float

Outer diameter of the Torx profile.

shape()[source]

Return the Torx driver-recess mask geometry.

Examples

Generate an STL of a T30 Torx mask:

from pybosl2.parts.screw_drive import TorxMask
TorxMask(size=30, l=10).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Return type:

CsgSolid

show()[source]

Display the Torx driver-recess mask in the viewer.

Return type:

None

class pybosl2.parts.screw_drive.TorxMask2d(size)[source]

Bases: object

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

This is a 2-D shape; to generate an STL, extrude it with linear_extrude() first.

Examples

Generate an STL of a T30 Torx 2-D profile extruded 10 mm:

from pybosl2.parts.screw_drive import TorxMask2d
TorxMask2d(size=30).shape().linear_extrude(height=10).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
size : int

property size : int

Torx size number.

shape()[source]

Return the 2-D Torx profile.

Examples

Generate an STL of a T30 Torx 2-D profile extruded 10 mm:

from pybosl2.parts.screw_drive import TorxMask2d
TorxMask2d(size=30).shape().linear_extrude(height=10).show()
Loading 3-D preview…

⬇ Download STL mesh

Return type:

CsgSolid

show()[source]

Display the 2-D Torx profile in the viewer.

Return type:

None

class pybosl2.parts.screw_drive.RobertsonMask(size, l=None, angle=2.5, slop=0.0)[source]

Bases: object

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

Examples

A #2 Robertson recess:

from pybosl2.parts.screw_drive import RobertsonMask
RobertsonMask(size=2).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
size : str | int

l : float | None

angle : float

slop : float

property size : int

Robertson size number (0..4).

property l : float | None

Length of drive mask.

property angle : float

Taper angle of each face.

property slop : float

Slop enlargement.

shape()[source]

Return the Robertson driver-recess mask geometry.

Examples

Generate an STL of a #2 Robertson recess:

from pybosl2.parts.screw_drive import RobertsonMask
RobertsonMask(size=2).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Return type:

CsgSolid

show()[source]

Display the Robertson driver-recess mask in the viewer.

Return type:

None

pybosl2.parts.screw_drive.hex_mask(size, l, slop=0.0, center=False)

Alias for HexDriveMask.

Parameters:
size : float

l : float

slop : float

center : bool

Return type:

None

class pybosl2.parts.screw_drive.TorxSpec(size)[source]

Bases: object

Torx driver dimensions for one size (ISO 14583).

Construct with the size directly: TorxSpec(30).

Parameters:
size : int

outer_diameter : float
inner_diameter : float
depth : float
tip_rounding : float
inner_rounding : float
property diam : float

Outer diameter in mm.

as_tuple()[source]

(outer_diameter, inner_diameter, depth, tip_rounding, inner_rounding).

Return type:

tuple[float, float, float, float, float]

class pybosl2.parts.screw_drive.PhillipsSpec(size='#2')[source]

Bases: object

Phillips recess geometry for one bit size (ISO 4757). See PhillipsMask.

Construct with the size directly: PhillipsSpec(2) or PhillipsSpec("#2").

Parameters:
size : str | int

shaft : float
b : float
e : float
g : float
alpha : float
beta : float
depth(diameter)[source]

Recess depth needed to reach diameter for this Phillips size, or None.

Parameters:
diameter : float

Target diameter in mm.

Returns:

Depth in mm, or None if diameter is outside the shaft/g range.

Return type:

float | None

diam(depth)[source]

Recess diameter at the top when cut to depth for this Phillips size, or None.

Parameters:
depth : float

Depth in mm.

Returns:

Diameter in mm, or None if depth is outside the valid range.

Return type:

float | None

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:

from pybosl2.parts.screw_drive import PhillipsMask

PhillipsMask(size="#1").shape().show()
Loading 3-D preview…

⬇ Download STL mesh

A #2 Phillips recess:

from pybosl2.parts.screw_drive import PhillipsMask

PhillipsMask(size="#2").shape().show()
Loading 3-D preview…

⬇ Download STL mesh

A #3 Phillips recess:

from pybosl2.parts.screw_drive import PhillipsMask

PhillipsMask(size=3).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

robertson_mask

A #2 Robertson (square) recess:

from pybosl2.parts.screw_drive import RobertsonMask

RobertsonMask(size=2).shape().show()
Loading 3-D preview…

⬇ Download STL mesh