"""Threaded rod, inch series, Unified threads #0-80 to 1/2-20 (ASME B1.1), any length. Envelope model for assemblies: a plain cylinder at the basic major diameter D of ASME B1.1 (the thread is not modelled). One end is on the XY plane at the origin and the rod runs along +Z; `length` is in inches. The model is in millimetres (1 in = 25.4 mm). """ from steve import Model size = "1/4-20" # Thread (Unified, ASME B1.1) length = 12.0 # in Length material = "steel" # Material # Thread designation: nominal size THREADS = { "#0-80": "#0", "#1-64": "#1", "#1-72": "#1", "#2-56": "#2", "#2-64": "#2", "#3-48": "#3", "#3-56": "#3", "#4-40": "#4", "#4-48": "#4", "#5-40": "#5", "#5-44": "#5", "#6-32": "#6", "#6-40": "#6", "#8-32": "#8", "#8-36": "#8", "#10-24": "#10", "#10-32": "#10", "1/4-20": "1/4", "1/4-28": "1/4", "5/16-18": "5/16", "5/16-24": "5/16", "3/8-16": "3/8", "3/8-24": "3/8", "7/16-14": "7/16", "7/16-20": "7/16", "1/2-13": "1/2", "1/2-20": "1/2", } # Inches. ASME B1.1-1989 (R2001) basic major diameter D, https://www.engineersedge.com/screw_threads_chart.htm DIAMETERS = { "#0": 0.0600, "#1": 0.0730, "#2": 0.0860, "#3": 0.0990, "#4": 0.1120, "#5": 0.1250, "#6": 0.1380, "#8": 0.1640, "#10": 0.1900, "1/4": 0.2500, "5/16": 0.3125, "3/8": 0.3750, "7/16": 0.4375, "1/2": 0.5000, } # material choice: (STEVE material library id, appearance colour) MATERIALS = { "steel": ("steel-generic", "#b8bcc2"), # carbon steel, zinc plated "stainless-18-8": ("stainless-304", "#c9ccd0"), "stainless-316": ("stainless-316", "#c9ccd0"), } INCH = 25.4 d = DIAMETERS[THREADS[size]] * INCH rod_length = length * INCH material_id, colour = MATERIALS[material] model = Model() with model.sketch("rod_sketch", on="XY", name="Section") as sk: sk.circle("rod_circle", (0, 0), d / 2) model.extrude("rod", "rod_sketch", distance=rod_length, name="Rod") model.material(material_id, color=colour) result = model.result()