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:
objectA 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…- 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.
-
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:
objectA 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…- 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.
-
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:
objectAn 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…- 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.
-
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:
objectA 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…- Parameters:¶
- property teeth : int¶
Number of teeth.
-
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:
objectA 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…- Parameters:¶
-
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:
objectA (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…- 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.
-
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:
objectA 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…- Parameters:¶
-
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:
objectA 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…- 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.
-
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:
SpurGearA herringbone (double-helical) spur gear —
SpurGearwithherringbone=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…- 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:
objectThe 2-D path of one involute gear tooth, rack-carved with real undercut.
- Parameters:¶
-
static GearSpec.circular_pitch(circ_pitch=
None, mod=None, pitch=None, diam_pitch=None)[source]¶ Circular pitch (mm/tooth) from any pitch input.
-
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.
-
static GearSpec.module_value(circ_pitch=
None, mod=None, pitch=None, diam_pitch=None)[source]¶ Metric module from any pitch input.
- 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.
-
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.
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()
By metric module:
from pybosl2.parts.gears import SpurGear
SpurGear(mod=2, teeth=20, thickness=8, shaft_diam=5).shape().show()
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()
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()
ring_gear
An internal ring gear:
from pybosl2.parts.gears import RingGear
RingGear(circ_pitch=5, teeth=48, thickness=10).shape().show()
Thicker backing:
from pybosl2.parts.gears import RingGear
RingGear(circ_pitch=5, teeth=48, thickness=10, backing=30).shape().show()
A higher pressure angle:
from pybosl2.parts.gears import RingGear
RingGear(circ_pitch=5, teeth=48, thickness=10, pressure_angle=28).shape().show()
With a profile shift:
from pybosl2.parts.gears import RingGear
RingGear(circ_pitch=5, teeth=48, thickness=10, profile_shift=0.5).shape().show()
Helical:
from pybosl2.parts.gears import RingGear
RingGear(circ_pitch=5, teeth=48, thickness=15, helical=30).shape().show()
rack
A linear rack:
from pybosl2.parts.gears import Rack
Rack(pitch=5, teeth=10, thickness=5).shape().show()
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()
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()
By module:
from pybosl2.parts.gears import BevelGear
BevelGear(mod=4, teeth=20, face_width=10, pitch_angle=45, shaft_diam=6).shape().show()
worm
A single-start worm:
from pybosl2.parts.gears import Worm
Worm(circ_pitch=8, diameter=30, length=50).shape().show()
A 3-start worm:
from pybosl2.parts.gears import Worm
Worm(circ_pitch=8, diameter=30, length=50, starts=3).shape().show()
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()
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()
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()
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()
By module:
from pybosl2.parts.gears import WormGear
WormGear(mod=2, teeth=32, worm_diam=30, worm_starts=1).shape().show()