"""Levelling foot envelope: a round base and a threaded stud (drawn at its nominal diameter), as step.parts' published models draw it, threads M6 to M12, base diameters 20 to 50 mm (any). The base (diameter `base_diameter`, thickness BASE_THICKNESS) sits on the XY plane, centred on the origin; the stud rises from its top along +Z, `stud_length` long. The swivel joint, the rubber pad and the nut are not modelled: the models draw every style with this same envelope. """ from steve import Model thread = "M8" # Stud thread base_diameter = 30 # mm Base diameter stud_length = 25 # mm Stud length (above the base) material = "unspecified" # Material # mm, measured on step.parts' models leveling_foot_m_d (cylinders of their two solids: base radius D/2 and 5 mm # thick in every model; stud radius = half the thread's nominal diameter, 25 mm long above the base) BASE_THICKNESS = 5.0 STUDS = {"M6": 6.0, "M8": 8.0, "M10": 10.0, "M12": 12.0} MATERIALS = { "unspecified": (None, None), # the models name no material "steel": ("steel-generic", "#9da2a8"), "stainless-304": ("stainless-304", "#c9ccd0"), } d = STUDS[thread] if base_diameter <= d: raise ValueError("The base must be wider than the stud.") material_id, colour = MATERIALS[material] model = Model() model.cylinder("base", base_diameter / 2, BASE_THICKNESS, name="Base") model.cylinder("stud", d / 2, stud_length, at=(0, 0, BASE_THICKNESS), op="join", name="Stud") if material_id: model.material(material_id, color=colour) result = model.result()