Gears

⚙️ Spec sheet →  —  visual schematic and metrics measured from a real rendered STL.

Pure-Python port of BOSL2’s current gears.scad. Gears are sized by circular pitch (circ_pitch), metric mod, or diam_pitch; the 20-degree pressure_angle and profile_shift="auto" defaults match BOSL2, so low-tooth-count gears automatically get the profile shift that avoids undercut. The involute spur teeth are rack-generated – the working involute flank plus the trochoid a meshing rack would carve – so low-tooth gears show a real undercut.

Includes the involute SpurGear2d / SpurGear (helical and/or herringbone), the internal RingGear, the linear Rack, the BevelGear, the Worm / WormGear pair, the dimension helpers on GearSpec (GearSpec.auto_profile_shift(), GearSpec.gear_dist() for the meshing centre distance).

class pybosl2.parts.gears.SpurGear(circ_pitch=None, teeth=11, thickness=6, shaft_diam=0, hide=0, pressure_angle=20, clearance=None, backlash=0.0, helical=0, herringbone=False, internal=False, profile_shift=None, shorten=0, slices=None, gear_spin=0, mod=None, pitch=None, diam_pitch=None, fn=None, fa=None, fs=None)[source]

Bases: object

A 3-D involute spur gear — helical and/or herringbone, with optional shaft bore.

Examples

A helical gear with a shaft bore:

from pybosl2.parts.gears import SpurGear
SpurGear(mod=5, teeth=18, thickness=25, helical=-29, shaft_diam=15).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
circ_pitch : float | None

teeth : int

thickness : float

shaft_diam : float

hide : int

pressure_angle : float

clearance : float | None

backlash : float

helical : float

herringbone : bool

internal : bool

profile_shift : float | None

shorten : float

slices : int | None

gear_spin : float

mod : float | None

pitch : float | None

diam_pitch : float | None

fn : int | None

fa : float | None

fs : float | None

property teeth : int

Number of teeth.

shape()[source]

Return the spur gear geometry.

Return type:

CsgSolid

show()[source]

Display the spur gear in the viewer.

Return type:

None

class pybosl2.parts.gears.SpurGear2d(circ_pitch=None, teeth=11, hide=0, pressure_angle=20, clearance=None, backlash=0.0, internal=False, profile_shift=None, helical=0, shaft_diam=0, shorten=0, gear_spin=0, mod=None, pitch=None, diam_pitch=None)[source]

Bases: object

A 2-D involute spur gear outline.

Examples

A 30-tooth metric gear:

from pybosl2.parts.gears import SpurGear2d
SpurGear2d(mod=5, teeth=30).shape().linear_extrude(height=3).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
circ_pitch : float | None

teeth : int

hide : int

pressure_angle : float

clearance : float | None

backlash : float

internal : bool

profile_shift : float | None

helical : float

shaft_diam : float

shorten : float

gear_spin : float

mod : float | None

pitch : float | None

diam_pitch : float | None

property teeth : int

Number of teeth.

shape()[source]

Return the 2-D gear outline.

Return type:

CsgShape2D

show()[source]

Display the gear in the viewer.

Return type:

None

class pybosl2.parts.gears.RingGear(circ_pitch=None, teeth=11, thickness=6, backing=3, pressure_angle=20, clearance=None, backlash=0.0, helical=0, profile_shift=None, mod=None, pitch=None, diam_pitch=None, fn=None, fa=None, fs=None)[source]

Bases: object

An internal (ring) gear: a disk with inward-facing teeth cut into its bore.

Examples

from pybosl2.parts.gears import RingGear
RingGear(teeth=30, thickness=8, pressure_angle=14.5, helical=20).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
circ_pitch : float | None

teeth : int

thickness : float

backing : float

pressure_angle : float

clearance : float | None

backlash : float

helical : float

profile_shift : float | None

mod : float | None

pitch : float | None

diam_pitch : float | None

fn : int | None

fa : float | None

fs : float | None

property teeth : int

Number of teeth.

shape()[source]

Return the ring gear geometry.

Return type:

CsgSolid

show()[source]

Display the ring gear in the viewer.

Return type:

None

class pybosl2.parts.gears.Rack(circ_pitch=None, teeth=20, thickness=5, height=10, pressure_angle=20, backlash=0.0, clearance=None, helical=0, mod=None, pitch=None, diam_pitch=None)[source]

Bases: object

A 3-D rack: a linear toothed bar a gear rolls along.

Examples

A rack to mesh with a spur gear:

from pybosl2.parts.gears import Rack
Rack(mod=5, teeth=20, thickness=10, height=12).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
circ_pitch : float | None

teeth : int

thickness : float

height : float

pressure_angle : float

backlash : float

clearance : float | None

helical : float

mod : float | None

pitch : float | None

diam_pitch : float | None

property teeth : int

Number of teeth.

shape()[source]

Return the rack geometry.

Return type:

CsgSolid

show()[source]

Display the rack in the viewer.

Return type:

None

class pybosl2.parts.gears.Rack2d(circ_pitch=None, teeth=20, height=10, pressure_angle=20, backlash=0.0, clearance=None, mod=None, pitch=None, diam_pitch=None)[source]

Bases: object

A 2-D involute rack outline — a straight bar of teeth.

Examples

A 2-D rack extruded for STL export:

from pybosl2.parts.gears import Rack2d
Rack2d(mod=2, teeth=20, height=10).shape().linear_extrude(height=5).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
circ_pitch : float | None

teeth : int

height : float

pressure_angle : float

backlash : float

clearance : float | None

mod : float | None

pitch : float | None

diam_pitch : float | None

shape()[source]

Return the 2-D rack outline.

Return type:

CsgShape2D

show()[source]

Display the rack in the viewer.

Return type:

None

class pybosl2.parts.gears.BevelGear(circ_pitch=None, teeth=20, face_width=10, pitch_angle=45, mate_teeth=None, shaft_diam=0, hide=0, pressure_angle=20, clearance=None, backlash=0.0, cutter_radius=30, spiral_angle=35, left_handed=False, slices=5, interior=False, mod=None, pitch=None, diam_pitch=None, fn=None, fa=None, fs=None)[source]

Bases: object

A (potentially spiral) involute bevel gear.

Examples

A bevel gear with a shaft bore:

from pybosl2.parts.gears import BevelGear
BevelGear(mod=5, teeth=30, face_width=10, pitch_angle=45, shaft_diam=15).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
circ_pitch : float | None

teeth : int

face_width : float

pitch_angle : float

mate_teeth : int | None

shaft_diam : float

hide : int

pressure_angle : float

clearance : float | None

backlash : float

cutter_radius : float

spiral_angle : float

left_handed : bool

slices : int

interior : bool

mod : float | None

pitch : float | None

diam_pitch : float | None

fn : int | None

fa : float | None

fs : float | None

property teeth : int

Number of teeth.

shape()[source]

Return the bevel gear geometry.

Return type:

CsgSolid

show()[source]

Display the bevel gear in the viewer.

Return type:

None

class pybosl2.parts.gears.Worm(circ_pitch=None, diameter=30, length=100, starts=1, left_handed=False, pressure_angle=20, backlash=0.0, clearance=None, mod=None, pitch=None, diam_pitch=None)[source]

Bases: object

A worm — a screw that meshes a worm gear.

Examples

A worm with two starts:

from pybosl2.parts.gears import Worm
Worm(mod=5, diameter=30, length=80, starts=2).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
circ_pitch : float | None

diameter : float

length : float

starts : int

left_handed : bool

pressure_angle : float

backlash : float

clearance : float | None

mod : float | None

pitch : float | None

diam_pitch : float | None

shape()[source]

Return the worm geometry.

Return type:

CsgSolid

show()[source]

Display the worm in the viewer.

Return type:

None

class pybosl2.parts.gears.WormGear(circ_pitch=None, teeth=36, worm_diam=30, worm_starts=1, worm_arc=60, crowning=1, left_handed=False, pressure_angle=20, backlash=0.0, slices=10, clearance=None, shaft_diam=0, mod=None, pitch=None, diam_pitch=None, fn=None, fa=None, fs=None)[source]

Bases: object

A worm gear, hobbed to mesh a matching Worm.

Examples

A worm gear with a shaft bore:

from pybosl2.parts.gears import WormGear
WormGear(mod=5, teeth=36, worm_diam=30, shaft_diam=15).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
circ_pitch : float | None

teeth : int

worm_diam : float

worm_starts : int

worm_arc : float

crowning : float

left_handed : bool

pressure_angle : float

backlash : float

slices : int

clearance : float | None

shaft_diam : float

mod : float | None

pitch : float | None

diam_pitch : float | None

fn : int | None

fa : float | None

fs : float | None

property teeth : int

Number of teeth.

shape()[source]

Return the worm gear geometry.

Return type:

CsgSolid

show()[source]

Display the worm gear in the viewer.

Return type:

None

class pybosl2.parts.gears.HerringboneGear(circ_pitch=None, teeth=11, thickness=6, shaft_diam=0, hide=0, pressure_angle=20, clearance=None, backlash=0.0, helical=0, internal=False, profile_shift=None, shorten=0, gear_spin=0, mod=None, pitch=None, diam_pitch=None, fn=None, fa=None, fs=None)[source]

Bases: SpurGear

A herringbone (double-helical) spur gear — SpurGear with herringbone=True.

Examples

A herringbone gear with a shaft bore:

from pybosl2.parts.gears import HerringboneGear
HerringboneGear(mod=5, teeth=18, thickness=25, helical=30, shaft_diam=15).show()
Loading 3-D preview…

⬇ Download STL mesh

Parameters:
circ_pitch : float | None

teeth : int

thickness : float

shaft_diam : float

hide : int

pressure_angle : float

clearance : float | None

backlash : float

helical : float

internal : bool

profile_shift : float | None

shorten : float

gear_spin : float

mod : float | None

pitch : float | None

diam_pitch : float | None

fn : int | None

fa : float | None

fs : float | None

class pybosl2.parts.gears.GearToothProfile(circ_pitch=None, teeth=11, pressure_angle=20, clearance=None, backlash=0.0, helical=0, internal=False, profile_shift=None, shorten=0, center=False, mod=None, pitch=None, diam_pitch=None)[source]

Bases: object

The 2-D path of one involute gear tooth, rack-carved with real undercut.

Parameters:
circ_pitch : float | None

teeth : int

pressure_angle : float

clearance : float | None

backlash : float

helical : float

internal : bool

profile_shift : float | None

shorten : float

center : bool

mod : float | None

pitch : float | None

diam_pitch : float | None

path()[source]

Return the tooth profile as a 2-D point list.

Returns:

List of [x, y] points defining the tooth profile.

Return type:

list[list[float]]

static GearSpec.circular_pitch(circ_pitch=None, mod=None, pitch=None, diam_pitch=None)[source]

Circular pitch (mm/tooth) from any pitch input.

Parameters:
circ_pitch : float | None

Circular pitch in mm/tooth.

mod : float | None

Metric module (mm/tooth).

pitch : float | None

Circular pitch alias.

diam_pitch : float | None

Diametral pitch (teeth per inch of pitch diameter).

Returns:

Resolved circular pitch in mm/tooth.

Return type:

float

static GearSpec.diametral_pitch_func(circ_pitch=None, mod=None, pitch=None, diam_pitch=None)[source]

Diametral pitch (teeth per inch of pitch diameter) from any pitch input.

Parameters:
circ_pitch : float | None

Circular pitch in mm/tooth.

mod : float | None

Metric module (mm/tooth).

pitch : float | None

Circular pitch alias.

diam_pitch : float | None

Diametral pitch (teeth per inch of pitch diameter).

Returns:

Diametral pitch value.

Return type:

float

static GearSpec.module_value(circ_pitch=None, mod=None, pitch=None, diam_pitch=None)[source]

Metric module from any pitch input.

Parameters:
circ_pitch : float | None

Circular pitch in mm/tooth.

mod : float | None

Metric module (mm/tooth).

pitch : float | None

Circular pitch alias.

diam_pitch : float | None

Diametral pitch (teeth per inch of pitch diameter).

Returns:

Metric module value.

Return type:

float

static GearSpec.pitch_value(mod)[source]

Circular pitch from the metric module.

Parameters:
mod : float

Metric module (mm/tooth).

Returns:

Circular pitch in mm/tooth.

Return type:

float

GearSpec.pitch_radius

Pitch-circle radius.

GearSpec.outer_radius

Outer (tip) radius.

GearSpec.root_radius

Root radius.

GearSpec.base_radius

Base-circle radius of the involute.

static GearSpec.auto_profile_shift(teeth, pressure_angle=20, helical=0, profile_shift=None)[source]

Minimum profile shift (modules) to avoid undercut.

Parameters:
teeth : int

Number of teeth on the gear.

pressure_angle : float

Pressure angle in degrees.

helical : float

Helical angle in degrees.

profile_shift : float | None

Explicit profile shift override, or None for auto.

Returns:

Profile shift value (modules).

Return type:

float

static GearSpec.gear_dist(teeth1, teeth2, helical=0, profile_shift1=None, profile_shift2=None, internal1=False, internal2=False, backlash=0, pressure_angle=20, circ_pitch=None, mod=None, diam_pitch=None)[source]

Center-to-center distance for two meshing gears.

Parameters:
teeth1 : int

Number of teeth on the first gear.

teeth2 : int

Number of teeth on the second gear.

helical : float

Helical angle in degrees.

profile_shift1 : float | None

Profile shift for the first gear, or None for auto.

profile_shift2 : float | None

Profile shift for the second gear, or None for auto.

internal1 : bool

True if the first gear is an internal (ring) gear.

internal2 : bool

True if the second gear is an internal (ring) gear.

backlash : float

Backlash amount in mm.

pressure_angle : float

Pressure angle in degrees.

circ_pitch : float | None

Circular pitch in mm/tooth.

mod : float | None

Metric module (mm/tooth).

diam_pitch : float | None

Diametral pitch (teeth per inch of pitch diameter).

Returns:

Center-to-center meshing distance in mm.

Return type:

float

static GearSpec.worm_gear_thickness(circ_pitch=None, teeth=30, worm_diam=30, worm_arc=60, crowning=1, clearance=None, mod=None, pitch=None, diam_pitch=None)[source]

Thickness of a worm gear matched to a worm.

Parameters:
circ_pitch : float | None

Circular pitch in mm/tooth.

teeth : int

Number of teeth on the worm gear.

worm_diam : float

Diameter of the mating worm.

worm_arc : float

Arc angle the worm gear wraps around the worm.

crowning : float

Crowning amount.

clearance : float | None

Clearance, or None for default.

mod : float | None

Metric module (mm/tooth).

pitch : float | None

Circular pitch alias.

diam_pitch : float | None

Diametral pitch (teeth per inch of pitch diameter).

Returns:

Worm gear thickness in mm.

Return type:

float

static GearSpec.bevel_pitch_angle(teeth, mate_teeth, drive_angle=90)[source]

Pitch angle (deg) for a bevel gear meshing another.

Parameters:
teeth : int

Number of teeth on the gear.

mate_teeth : float

Number of teeth on the mating gear.

drive_angle : float

Shaft angle between gears in degrees.

Returns:

Pitch angle in degrees.

Return type:

float

Examples

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

spur_gear

A spur gear by circular pitch:

from pybosl2.parts.gears import SpurGear
SpurGear(circ_pitch=5, teeth=20, thickness=8, shaft_diam=5).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

By metric module:

from pybosl2.parts.gears import SpurGear
SpurGear(mod=2, teeth=20, thickness=8, shaft_diam=5).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

A helical gear:

from pybosl2.parts.gears import SpurGear
SpurGear(circ_pitch=5, teeth=20, thickness=10, shaft_diam=5, helical=-30, slices=12).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

A herringbone gear:

from pybosl2.parts.gears import SpurGear
SpurGear(circ_pitch=5, teeth=20, thickness=10, shaft_diam=5, helical=30, herringbone=True, slices=5).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

ring_gear

An internal ring gear:

from pybosl2.parts.gears import RingGear
RingGear(circ_pitch=5, teeth=48, thickness=10).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Thicker backing:

from pybosl2.parts.gears import RingGear
RingGear(circ_pitch=5, teeth=48, thickness=10, backing=30).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

A higher pressure angle:

from pybosl2.parts.gears import RingGear
RingGear(circ_pitch=5, teeth=48, thickness=10, pressure_angle=28).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

With a profile shift:

from pybosl2.parts.gears import RingGear
RingGear(circ_pitch=5, teeth=48, thickness=10, profile_shift=0.5).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Helical:

from pybosl2.parts.gears import RingGear
RingGear(circ_pitch=5, teeth=48, thickness=15, helical=30).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

rack

A linear rack:

from pybosl2.parts.gears import Rack
Rack(pitch=5, teeth=10, thickness=5).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

A rack at 14.5 deg pressure angle:

from pybosl2.parts.gears import Rack
Rack(mod=2, teeth=10, thickness=5, pressure_angle=14.5).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

bevel_gear

A 45 deg bevel gear:

from pybosl2.parts.gears import BevelGear
BevelGear(circ_pitch=5, teeth=36, mate_teeth=36, shaft_diam=5).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

By module:

from pybosl2.parts.gears import BevelGear
BevelGear(mod=4, teeth=20, face_width=10, pitch_angle=45, shaft_diam=6).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

worm

A single-start worm:

from pybosl2.parts.gears import Worm
Worm(circ_pitch=8, diameter=30, length=50).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

A 3-start worm:

from pybosl2.parts.gears import Worm
Worm(circ_pitch=8, diameter=30, length=50, starts=3).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

A left-handed 3-start worm:

from pybosl2.parts.gears import Worm
Worm(circ_pitch=8, diameter=30, length=50, starts=3, left_handed=True).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

worm_gear

A worm gear:

from pybosl2.parts.gears import WormGear
WormGear(circ_pitch=5, teeth=36, worm_diam=30, worm_starts=1).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Left-handed:

from pybosl2.parts.gears import WormGear
WormGear(circ_pitch=5, teeth=36, worm_diam=30, worm_starts=1, left_handed=True).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

Meshing a 4-start worm:

from pybosl2.parts.gears import WormGear
WormGear(circ_pitch=5, teeth=36, worm_diam=30, worm_starts=4).shape().show()
Loading 3-D preview…

⬇ Download STL mesh

By module:

from pybosl2.parts.gears import WormGear
WormGear(mod=2, teeth=32, worm_diam=30, worm_starts=1).shape().show()
Loading 3-D preview…

⬇ Download STL mesh