114 lines
3.0 KiB
Python
114 lines
3.0 KiB
Python
from build123d import *
|
|
from ocp_vscode import show
|
|
|
|
|
|
scianka = 3
|
|
zaokraglenie = 5
|
|
|
|
# parametry boxa
|
|
dlugosc = 200
|
|
szerokosc = 180
|
|
wysokosc = 60
|
|
|
|
# parametry koszyszka
|
|
dlkoszyczek = 40
|
|
szerkoszyczek = 40
|
|
scianka_koszyczka = 2
|
|
|
|
# lid
|
|
wyspok = 20
|
|
|
|
with BuildPart() as box:
|
|
# podstawa = Box(200, 180, 50)
|
|
with BuildSketch() as s1:
|
|
Rectangle(dlugosc, szerokosc)
|
|
extrude(amount=wysokosc)
|
|
offset(amount=-scianka, openings=box.faces().sort_by(Axis.Z)[-1])
|
|
bottom = box.faces().filter_by(Axis.Z)[-1]
|
|
ver = (
|
|
box.faces()
|
|
.filter_by(Axis.Z)[-1]
|
|
.edges()
|
|
.filter_by(Axis.X)
|
|
.sort_by(Axis.Y)[-1]
|
|
.vertices()
|
|
.sort_by(Axis.X)[0]
|
|
)
|
|
pts = [
|
|
(ver.X + dlkoszyczek, ver.Y),
|
|
(ver.X + dlkoszyczek, ver.Y - szerkoszyczek),
|
|
(ver.X, ver.Y - szerkoszyczek),
|
|
]
|
|
with BuildSketch() as rys:
|
|
with BuildLine() as l1:
|
|
t1 = Polyline(pts)
|
|
t2 = offset(amount=scianka, side=Side.RIGHT)
|
|
t3 = make_face()
|
|
extrude(amount=wysokosc)
|
|
mirror(about=Plane.YZ)
|
|
t4 = box.vertices()
|
|
ver2 = (
|
|
box.faces()
|
|
.filter_by(Axis.Z)[2]
|
|
.edges()
|
|
.filter_by(Axis.Y)
|
|
.sort_by(Axis.X)[1]
|
|
.vertices()
|
|
.sort_by(Axis.Y)[0]
|
|
)
|
|
ver3 = (
|
|
box.faces()
|
|
.filter_by(Axis.Z)[2]
|
|
.edges()
|
|
.filter_by(Axis.Y)
|
|
.sort_by(Axis.X)[2]
|
|
.vertices()
|
|
.sort_by(Axis.Y)[0]
|
|
)
|
|
with BuildSketch() as rys2:
|
|
with BuildLine() as l2:
|
|
Polyline((ver2.X, ver2.Y), (ver3.X, ver3.Y))
|
|
offset(amount=scianka, side=Side.LEFT)
|
|
make_face()
|
|
extrude(amount=wysokosc)
|
|
face_belka = box.faces().filter_by(Axis.Z)[2]
|
|
with BuildSketch(face_belka) as ff:
|
|
Rectangle(dlugosc - 2 * scianka, scianka)
|
|
extrude(amount=wysokosc - scianka)
|
|
filetki1 = box.faces().sort_by(Axis.Y)[0].edges().filter_by(Axis.Z)
|
|
filetki2 = box.faces().sort_by(Axis.Y)[-1].edges().filter_by(Axis.Z)
|
|
filterki = [filetki1, filetki2]
|
|
fillet(filterki, radius=zaokraglenie)
|
|
|
|
|
|
with BuildPart() as lid:
|
|
with BuildSketch() as s1:
|
|
Rectangle(dlugosc + scianka + 0.2, szerokosc + scianka + 0.2)
|
|
extrude(amount=wyspok)
|
|
filetki3 = lid.faces().sort_by(Axis.X)[0].edges().filter_by(Axis.Z)
|
|
filetki4 = lid.faces().sort_by(Axis.X)[-1].edges().filter_by(Axis.Z)
|
|
filetki_lid = [filetki3 + filetki4]
|
|
fillet(filetki_lid, radius=zaokraglenie)
|
|
offset(amount=-1.5, openings=lid.faces().sort_by(Axis.Z)[0])
|
|
gora_lid = lid.faces().sort_by(Axis.Z)[-1]
|
|
with BuildSketch(gora_lid) as tu:
|
|
Text("Others", font_size=40)
|
|
# Rectangle(20, 20)
|
|
extrude(amount=-1, mode=Mode.SUBTRACT)
|
|
|
|
with BuildPart() as polaczone:
|
|
add(box)
|
|
with Locations((0, 0, wysokosc)):
|
|
add(lid)
|
|
|
|
export_stl(lid.part, "./lid.stl")
|
|
# export_stl(box.part, "./box.stl")
|
|
|
|
# show_object(lid)
|
|
# show_object(polaczone)
|
|
|
|
|
|
# debug(gora_lid)
|
|
# debug(tu.sketch)
|
|
# show_object(polaczone, name="polaczone", options={"alpha": 0.5, "color": "red"})
|