73 lines
2.2 KiB
Python
73 lines
2.2 KiB
Python
"""Parametric V1 connecting-rod sample routed to the build123d backend."""
|
|
|
|
from build123d import Align, Box, BuildPart, BuildSketch, Cylinder, Location, Locations, Mode, Plane, SlotOverall, extrude
|
|
|
|
|
|
CENTER_DISTANCE = 120.0
|
|
THICKNESS = 14.0
|
|
|
|
BIG_END_OUTER_DIAMETER = 56.0
|
|
BIG_END_BORE_DIAMETER = 36.0
|
|
SMALL_END_OUTER_DIAMETER = 36.0
|
|
SMALL_END_BORE_DIAMETER = 20.0
|
|
|
|
WEB_WIDTH = 24.0
|
|
POCKET_LENGTH = 72.0
|
|
POCKET_WIDTH = 12.0
|
|
POCKET_DEPTH = 3.0
|
|
|
|
|
|
def gen_step():
|
|
"""Return a closed, STEP-ready connecting-rod solid in millimeters."""
|
|
half_distance = CENTER_DISTANCE / 2.0
|
|
|
|
with BuildPart() as rod:
|
|
with Locations(Location((-half_distance, 0.0, 0.0))):
|
|
Cylinder(
|
|
radius=BIG_END_OUTER_DIAMETER / 2.0,
|
|
height=THICKNESS,
|
|
align=(Align.CENTER, Align.CENTER, Align.MIN),
|
|
)
|
|
|
|
with Locations(Location((half_distance, 0.0, 0.0))):
|
|
Cylinder(
|
|
radius=SMALL_END_OUTER_DIAMETER / 2.0,
|
|
height=THICKNESS,
|
|
align=(Align.CENTER, Align.CENTER, Align.MIN),
|
|
)
|
|
|
|
Box(
|
|
CENTER_DISTANCE,
|
|
WEB_WIDTH,
|
|
THICKNESS,
|
|
align=(Align.CENTER, Align.CENTER, Align.MIN),
|
|
)
|
|
|
|
with Locations(Location((-half_distance, 0.0, -1.0))):
|
|
Cylinder(
|
|
radius=BIG_END_BORE_DIAMETER / 2.0,
|
|
height=THICKNESS + 2.0,
|
|
align=(Align.CENTER, Align.CENTER, Align.MIN),
|
|
mode=Mode.SUBTRACT,
|
|
)
|
|
|
|
with Locations(Location((half_distance, 0.0, -1.0))):
|
|
Cylinder(
|
|
radius=SMALL_END_BORE_DIAMETER / 2.0,
|
|
height=THICKNESS + 2.0,
|
|
align=(Align.CENTER, Align.CENTER, Align.MIN),
|
|
mode=Mode.SUBTRACT,
|
|
)
|
|
|
|
with BuildSketch(Plane.XY):
|
|
SlotOverall(width=POCKET_LENGTH, height=POCKET_WIDTH)
|
|
extrude(amount=POCKET_DEPTH, mode=Mode.SUBTRACT)
|
|
|
|
with BuildSketch(Plane.XY.offset(THICKNESS - POCKET_DEPTH)):
|
|
SlotOverall(width=POCKET_LENGTH, height=POCKET_WIDTH)
|
|
extrude(amount=POCKET_DEPTH, mode=Mode.SUBTRACT)
|
|
|
|
result = rod.part
|
|
result.label = "cad_router_v1_connecting_rod"
|
|
return result
|