opel-cad/opel_pin.py

97 lines
3.6 KiB
Python
Raw Normal View History

2026-06-26 11:36:45 +02:00
from build123d import *
from ocp_vscode import show
# ==========================================
2026-06-26 22:25:15 +02:00
# --- 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
2026-06-26 11:36:45 +02:00
# ==========================================
# --- Derived Parameters ---
outer_diameter = model_size
inner_diameter = model_size * (25.4 / 31.0)
thickness = model_size * (2.3 / 31.0)
2026-06-26 11:36:45 +02:00
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)
2026-06-26 11:36:45 +02:00
# --- Lightning Bolt Proportions ---
2026-06-26 22:25:15 +02:00
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)
# ==========================================
2026-06-26 11:36:45 +02:00
# ==========================================
# --- 2. BUILD THE OPEL LOGO ---
2026-06-26 11:36:45 +02:00
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)
2026-06-26 22:25:15 +02:00
# 2. Lightning Bolt Profile (Aggressive Z-Shape)
2026-06-26 11:36:45 +02:00
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)
2026-06-26 11:36:45 +02:00
]
2026-06-26 23:06:46 +02:00
z_shape = Polygon(*pts)
fillet(z_shape.vertices(), radius=fillet_radius)
2026-06-26 22:25:15 +02:00
Circle(W, mode=Mode.INTERSECT)
2026-06-26 11:36:45 +02:00
extrude(amount=thickness)
# 3. Fillet ALL top edges
2026-06-26 23:06:46 +02:00
top_face = opel_pin.faces().sort_by(Axis.Z)[-1]
fillet(top_face.edges(), radius=fillet_radius)
2026-06-26 23:06:46 +02:00
# 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)
# ==========================================
2026-06-26 11:36:45 +02:00
2026-06-26 23:06:46 +02:00
# --- Export for 3D Printing ---
export_step(opel_pin.part, "vintage_opel_pin.step")
2026-06-26 11:36:45 +02:00
# --- Send to OCP CAD Viewer ---
show(opel_pin)