tootalltoby/post_cap.py

46 lines
1.4 KiB
Python

"""
Too Tall Toby Party Pack 01-02 Post Cap
"""
from build123d import *
densa = 7800 / 1e6 # carbon steel density g/mm^3
densb = 2700 / 1e6 # aluminum alloy
densc = 1020 / 1e6 # ABS
with BuildPart() as p:
with BuildSketch(Plane.XZ) as s:
Rectangle(49, 48 - 8, align=(Align.CENTER, Align.MIN)) # wysokość 40
with Locations((0, 40)):
Rectangle(9, 8, align=(Align.CENTER, Align.MIN))
with Locations((4.5, 40)):
Ellipse(20 , 8)
split(bisect_by=Plane.YZ)
revolve(axis=Axis.Z)
with BuildLine(Plane.XZ) as l1:
ucho = CenterArc(center=(-15, 20), radius=17, start_angle=90, arc_size=180)
punkt1 = ucho @ (0)
# print(punkt1)
with BuildSketch(Plane.ZY.offset(15)) as s2:
with Locations((punkt1.Z, 0)):
Ellipse(4 / 2, 10 / 2)
sweep(path=ucho)
# with BuildPart() as bo:
with BuildSketch(Plane.XZ) as s1:
Trapezoid(42, 37, 86, align=(Align.CENTER, Align.MIN))
split(bisect_by=Plane.YZ)
t3 = revolve(axis=Axis.Z, mode=Mode.PRIVATE)
krawedz = t3.faces().sort_by(Axis.Z)[-1].edge()
# t5 = fillet(t4, 1.5)
t3 = t3.fillet(radius=1.5, edge_list=[krawedz])
add(t3, mode=Mode.SUBTRACT)
show_object(p)
got_mass = p.part.volume * densc
want_mass = 43.09
tolerance = 1
delta = abs(got_mass - want_mass)
print(f"Mass: {got_mass:0.2f} g")
assert delta < tolerance, f'{got_mass=}, {want_mass=}, {delta=}, {tolerance=}'