Gears#

Recognize spur and helical gears, external and internal, and read the parameters they are specified with.

Note

Prerequisites: Attributed Adjacency Graph (AAG)

Tip

Tutorial Data Files:

Gear Recognition#

GearShapeRecognizer reads a gear from its faces: a ring of identical involute teeth about an axis, and the body that carries them. It reads spur and helical gears, external and internal, and gives back a GearShape holding the parameters a gear is specified with. A part that is not a gear is refused, with the reason.


Quick Start#

import gzip
from io import BytesIO

from volmdlr import shapes

from volmdlr_tools.shapes.recognizers import GearShapeRecognizer


def load(path):
    with open(path, "rb") as file:
        return shapes.Solid.from_brep(BytesIO(gzip.decompress(file.read())))


recognizer = GearShapeRecognizer(shape=load("data/gear/alpha_25.brep.gz"))
gear = recognizer.result
print(gear.tooth_count, round(gear.module, 6), gear.pressure_angle, gear.internal, gear.hand)
# 20 2.0 25.0 False None
print(round(gear.tip_radius, 6), round(gear.root_radius, 6), round(gear.pitch_radius, 6), gear.face_width)
# 22.0 17.5 20.0 6.0
print(gear.axis_direction, len(gear.tooth_face_ids), len(gear.body_face_ids))
# Vector3D(0.0, 0.0, 1.0) 120 2

The gear alpha_25 with its tooth faces coloured

alpha_25.brep.gz as read: the 120 tooth faces (tooth_face_ids) in blue, the two body faces (body_face_ids), its flat ends, in sand.


GearShapeRecognizer#

GearShapeRecognizer(
    shape: Union[shapes.Shell, shapes.Solid],
    aag: Optional[AttributedAdjacencyGraph] = None,
    linear_tolerance: Optional[float] = None,
    name: str = "",
)
  • shape: the part to read.

  • aag: a face adjacency graph of the part, when you already have one.

  • linear_tolerance: the tolerance on lengths; it defaults to a small share of the part’s size.

Member

Description

perform()

Read the part; True when it is a gear

result

The GearShape, or None when the part is not a gear

refusal

Why the part is not a gear, as a NotAGear; None when it is one

Reading result or refusal runs the recognition the first time.

When the part is not a gear#

NotAGear is a FaceRefusal: it carries a reason, the face_ids it is about (empty when it is about the whole part) and, when known, their area. A part with a ring of identical faces about an axis is not a gear unless those faces are teeth with mirrored flanks:

recognizer = GearShapeRecognizer(shape=load("data/gear/polygon_prism.brep.gz"))
print(recognizer.result)
# None
print(recognizer.refusal.reason)
# no two mirrored classes of flank faces repeat round the axis

What a GearShape holds#

Lengths are in the part’s units and angles in degrees. Angles about the axis are measured from reference_direction, positive by the right hand about the axis direction.

Attribute

Description

axis_origin

The point of the axis level with the end of the teeth the axis direction leaves from

axis_direction

The unit axis direction

tooth_count

The number of teeth

module

The pitch diameter divided by the tooth count

pressure_angle

The angle of the flanks to the radius at the pitch circle, rounded to a standard value (14.5°, 20°, 22.5° or 25°) when it lies within half a degree of one

measured_pressure_angle

The pressure angle the flanks show, before it is rounded

tip_radius / root_radius

The tip and root circles; the tip circle lies inside the root circle on an internal gear

face_width

The length of the teeth along the axis

internal

Whether the teeth point at the axis

helix_angle

The angle of the teeth to the axis at the pitch circle; 0.0 for straight teeth

hand

"right" or "left" for a helical gear, None for straight teeth

phase

The angle of the tooth centre nearest the reference direction at the start of the face width

root_fillet / tip_round

The radius of the blend between flank and root, and between flank and tip; None when there is none

tip_chamfers

The chamfers on the tooth tips at either end, as ToothChamfers (end, length along the axis, radial depth, and angle to the axis)

tooth_face_ids

The faces of the teeth

body_face_ids

The other faces of the part

body

The body carrying the teeth, read as a turned body (RevolvedShape); None when it is not read

Derived values: pitch_radius, addendum (pitch circle to tip circle), dedendum (pitch circle to root circle), base_radius and reference_direction. validate() checks that the parameters describe a gear, and extract_features() returns them as a dictionary, the body under "body".

Building the teeth again#

teeth_code(length_scale=1000.0, tip_fillet=False) returns Python source that builds the teeth with a gear library, placed and turned as they are in the part. The code binds teeth: the gear itself for an external gear, and the toothed band between the tip and root circles for an internal one. What the call does not build, such as a blend, a tip chamfer or the helix of an internal gear, is written in the code as a comment rather than dropped.

length_scale turns the part’s lengths into the code’s; the default turns metres into millimetres, so pass 1.0 for a part that is already in millimetres. tip_fillet=True passes the tip blend to the library instead of writing it as a comment.


Limitations#

  • Only spur and helical gears are read: the teeth must be involute, identical and evenly spaced all the way round the axis.

  • The code teeth_code() writes builds an internal gear as a straight band; its helix is written as a comment.


See Also#

See Also#