from build123d import * from ocp_vscode import show # ========================================== # --- MASTER PARAMETERS --- model_size = 31.0 # Outer diameter of the ring overhang = model_size * (3.0 / 31.0) # How many mm the bolt sticks out # ========================================== # --- Derived Parameters --- outer_diameter = model_size inner_diameter = model_size * (25.4 / 31.0) thickness = model_size * (2.3 / 31.0) pin_diameter = model_size * (3.1 / 31.0) pin_length = model_size * (10.8 / 31.0) pin_spacing = model_size * (14.0 / 31.0) pin_height_offset = model_size * (1.55 / 31.0) fillet_radius = model_size * (0.15 / 31.0) # --- Stud Parameters --- stud_stickout = model_size * (0.4 / 31.0) stud_thickness = model_size * (0.5 / 31.0) # --- Lightning Bolt Proportions --- W = (outer_diameter / 2) + overhang bound = model_size H_outer = model_size * (3.1 / 31.0) H_inner = model_size * (0.5 / 31.0) X_point = model_size * (5.8 / 31.0) X_inner = model_size * (2.7 / 31.0) # ========================================== # --- 1. BUILD THE MASTER PIN --- # We build a single fully-studded pin first. with BuildPart() as master_pin: # Build the smooth base cylinder Cylinder(radius=pin_diameter / 2, height=pin_length) # We will place 3 rows of studs vertically along the pin # We use 0.25 and -0.25 so the studs sit neatly along the middle shaft z_offsets = [pin_length * 0.25, 0, -pin_length * 0.25] for z in z_offsets: with Locations((0, 0, z)): # PolarLocations places local coordinate systems around a circle. # It naturally rotates so the local "X" axis points directly outward! with PolarLocations(radius=pin_diameter / 2, count=4): # A box is drawn. Since we want it sticking out by "stud_stickout", # we make its length exactly double that (half embeds into the pin, half sticks out) Box(length=stud_stickout * 2, width=stud_thickness, height=stud_thickness) # ========================================== # ========================================== # --- 2. BUILD THE OPEL LOGO --- with BuildPart() as opel_pin: # 1. Base Ring with BuildSketch() as ring_sketch: Circle(outer_diameter / 2) Circle(inner_diameter / 2, mode=Mode.SUBTRACT) extrude(amount=thickness) # 2. Lightning Bolt Profile (Aggressive Z-Shape) with BuildSketch() as bolt_sketch: pts = [ (-bound, H_outer), (-bound, -H_inner), (-X_inner, -H_inner), (-X_point, -H_outer), (bound, -H_outer), (bound, H_inner), (X_inner, H_inner), (X_point, H_outer) ] z_shape = Polygon(*pts) fillet(z_shape.vertices(), radius=fillet_radius) Circle(W, mode=Mode.INTERSECT) extrude(amount=thickness) # 3. Fillet ALL top edges top_face = opel_pin.faces().sort_by(Axis.Z)[-1] fillet(top_face.edges(), radius=fillet_radius) # 4. Attach the Studded Mounting Pins # Because the logo extrudes upwards from Z=0, the back is perfectly flat at Z=0. # We place our master_pin so its top (pin_length / 2) sits flush against the back. with Locations((-pin_spacing, pin_height_offset, -pin_length / 2), (pin_spacing, -pin_height_offset, -pin_length / 2)): add(master_pin.part) # ========================================== # --- Export for 3D Printing --- export_step(opel_pin.part, "vintage_opel_pin.step") # --- Send to OCP CAD Viewer --- show(opel_pin)