"""Hex head screw, inch series: hex cap screws to ASME B18.2.1 (1/4 to 1/2 in) and hex head machine screws to ASME B18.6.3 (#2 to #10), UNC and UNF, any length. Envelope model for assemblies: hexagon head (width across flats F, height H; corners and washer face not chamfered) and a plain shank at the basic major diameter D of ASME B1.1 (the thread is not modelled). The head's bearing face is on the XY plane at the origin, the head above it, the shank along -Z; `length` (inches) is the nominal length under the head. The model is in millimetres (1 in = 25.4 mm). """ from steve import Model size = "1/4-20" # Thread (Unified, ASME B1.1) length = 1.0 # in Nominal length under the head 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. D: ASME B1.1-1989 (R2001) basic major diameter, as reproduced at # https://www.engineersedge.com/screw_threads_chart.htm ("Major Diameter Basic"). # #2 to #10: ASME B18.6.3-2013 Table 29 (plain and slotted hex head machine screws, regular head), F max and H max # (the table has no basic column), as reproduced in Tanner's catalogue p. 72 (ASME B18.6.3-2002 table, same values) # https://www.tannerbolt.com/media/akeneo_connector/Machinehexhds.pdf and at https://torqbolt.com/asme-b18-6-3-plain-and-slotted-hexagon-head-machine-screws-dimensions-standards-specifications # 1/4 to 1/2: ASME B18.2.1-2012 Table 6 (hex cap screws), F basic and H basic, as reproduced at # https://torqbolt.com/asme-b18-2-1-hex-cap-screws-dimensions-standards-specifications and # https://www.aftfasteners.com/hex-cap-screws-head-thread-dimensions-performance-mechanical-specs/ # nominal: (D, F, H) DIMENSIONS = { "#2": (0.0860, 0.125, 0.050), "#4": (0.1120, 0.188, 0.060), "#6": (0.1380, 0.250, 0.093), "#8": (0.1640, 0.250, 0.110), "#10": (0.1900, 0.312, 0.120), "1/4": (0.2500, 0.4375, 0.15625), "5/16": (0.3125, 0.500, 0.203125), "3/8": (0.3750, 0.5625, 0.234375), "7/16": (0.4375, 0.625, 0.28125), "1/2": (0.5000, 0.750, 0.3125), } # 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, F, H = DIMENSIONS[THREADS[size]] d = D * INCH s = F * INCH k = H * INCH shank = length * INCH material_id, colour = MATERIALS[material] model = Model() with model.sketch("head_sketch", on="XY", name="Head") as sk: sk.polygon("hex", (0, 0), s / 2, 6, inscribed=False) model.extrude("head", "head_sketch", distance=k, name="Head") with model.sketch("shank_sketch", on="XY", name="Shank") as sk: sk.circle("shank_circle", (0, 0), d / 2) model.extrude("shank", "shank_sketch", distance=-shank, name="Shank") model.material(material_id, color=colour) result = model.result()