"""Open-ended GT2 (2GT) timing belt, straight, 2 mm pitch: length along X, centred on the origin, back of the belt up, teeth down on the XY plane. detail = "full": the teeth along the length; tooth width is a proportion for looks, not for design (only the height and pitch are published). A belt over 500 mm carries teeth along 250 mm at each end, the middle at full height: more teeth build too slowly for a belt. detail = "simple": a plain bar of the belt's overall height.""" import math from steve import Model width = 6 # mm Belt width length = 300 # mm Belt length detail = "full" # full: teeth; simple: a plain bar # Handson Technology, GT2 belt data sheet: 2 mm pitch, belt height 1.38 mm, tooth height 0.75 mm. HEIGHT = 1.38 TOOTH_HEIGHT = 0.75 PITCH = 2.0 TOOTH_WIDTH = 1.2 # a proportion for looks TOOTHED_LENGTH = 500 # mm: the most of a belt that carries drawn teeth model = Model() if detail == "simple": outline = [(-length / 2, 0), (length / 2, 0), (length / 2, HEIGHT), (-length / 2, HEIGHT)] else: back = TOOTH_HEIGHT outline = [(-length / 2, back), (-length / 2, HEIGHT), (length / 2, HEIGHT), (length / 2, back)] count = int(length // PITCH) centres = [(i - (count - 1) / 2) * PITCH for i in range(count)] if length > TOOTHED_LENGTH: # teeth at both ends, so an end view shows them kept = int(TOOTHED_LENGTH / 2 // PITCH) centres = centres[:kept] + centres[-kept:] for x in reversed(centres): half = TOOTH_WIDTH / 2 outline += [(x + half, back), (x + half * 0.6, 0.0), (x - half * 0.6, 0.0), (x - half, back)] with model.sketch("belt_sketch", on="XZ", name="Belt section") as sk: sk.polyline("outline", outline, closed=True) model.extrude("belt", "belt_sketch", distance=width, both=True, name="Belt") result = model.result()