"""Approximate threaded stud, roller body, and hex-end silhouette. The image does not define a thread standard. Rings represent the visible thread rhythm while keeping the concept model lightweight and editable. """ from math import atan2, degrees from build123d import Align, Axis, BuildPart, BuildSketch, Cylinder, Mode, Plane, Pos, RegularPolygon, extrude from shaft_common import add_thread_rings, cut_end_bore, export_horizontal, stepped_body def _hex_prism(z_start, across_corners, length): with BuildPart() as prism: with BuildSketch(Plane.XY.offset(z_start)): RegularPolygon(radius=across_corners / 2.0, side_count=6) extrude(amount=length) return prism.part def _radial_through_hole(body, axial_position, surface_y, surface_z, diameter, stock_diameter): # The source is authored along +Z and export_horizontal rotates it onto +X. source_x = -surface_z source_y = surface_y angle = degrees(atan2(source_y, source_x)) tool = ( Pos(0, 0, axial_position) * Cylinder( diameter / 2.0, stock_diameter + 4.0, align=(Align.CENTER, Align.CENTER, Align.CENTER), ) .rotate(Axis.Y, 90) .rotate(Axis.Z, angle) ) return body - tool def gen_step(): # Minor thread stem, neck, roller, and short nut-supporting neck. body, total = stepped_body([(8.2, 40.0), (9.5, 7.0), (28.0, 25.0), (10.0, 4.0)]) body = add_thread_rings(body, z_start=0.5, length=38.5, major_diameter=10.0, pitch=2.0) body = _radial_through_hole( body, axial_position=59.77433249254057, surface_y=0.8860768186618869, surface_z=13.963760796195984, diameter=4.0, stock_diameter=28.0, ) hex_body = _hex_prism(total - 0.15, across_corners=22.0, length=11.0) body = body + hex_body total += 10.85 body = cut_end_bore(body, total, diameter=8.0, depth=8.0) return export_horizontal(body, "threaded_roller_067249_like")