105 lines
4.3 KiB
Python
105 lines
4.3 KiB
Python
from build123d import *
|
|
from ocp_vscode import *
|
|
|
|
|
|
orange = import_step("./OrangePi-Box.step")
|
|
orange = orange.rotate(Axis.X, -90).move(Location((0, 0, 37)))
|
|
|
|
# (Twoje parametry pozostają bez zmian)
|
|
dlugosc = 112.80
|
|
szerokosc = 87.80
|
|
wysokosc = 54
|
|
scianka = 3
|
|
|
|
# --- Parametry otworów (skrócone dla czytelności kodu, wartości te same) ---
|
|
dl1o, sz1o, offset_x1, offset_y1 = 17.84, 11.68, 8.931, 18.295
|
|
dl2o, sz2o, offset_x2, offset_y2 = 24.103, 22.007, 27.894, 19.047
|
|
dl3o, sz3o, offset_x3, offset_y3 = 6.20, 8.40, 55.740, 14.770
|
|
dl4o, sz4o, offset_x4, offset_y4 = 26.577, 19.737, 70.481, 23.208
|
|
dl5o, sz5o, offset_x5, offset_y5 = 15.400, 20.400, 8.910, 16.720
|
|
dl6o, sz6o, offset_x6, offset_y6 = 10.200, 19.600, 27.160, 15.620
|
|
dl7o, sz7o, offset_x7, offset_y7 = 43.200, 20.200, 63.660, 17.820
|
|
|
|
# Parametry uchwytu
|
|
mini_udl, mini_usz, mini_ugr = 10, 8.500, 4
|
|
wyc_dl, wyc_sz, wyc_gr = 3, 3, 4.50
|
|
pods_dl, pods_sz, pods_gr = 12.820, 13.400, 1.7
|
|
offset_podstawy, przesuniecie_uchwyciku = 1.410, 17.080
|
|
|
|
with BuildPart() as box:
|
|
# --- Główna puszka ---
|
|
with BuildSketch() as s1:
|
|
Rectangle(dlugosc, szerokosc)
|
|
extrude(amount=wysokosc)
|
|
offset(amount=-scianka, openings=box.faces().sort_by(Axis.Z)[-1])
|
|
|
|
# --- Wycinanie otworów (Twoja logika, zgrupowana dla wydajności) ---
|
|
front = box.faces().sort_by(Axis.Y)[0]
|
|
# Punkt odniesienia frontu
|
|
v_front = front.edges().filter_by(Axis.Z).sort_by(Axis.X)[0].vertices()[0]
|
|
|
|
with BuildSketch(front):
|
|
with Locations((v_front.X + offset_x1, -offset_y1)): Rectangle(dl1o, sz1o, align=(Align.MIN, Align.MIN, Align.CENTER))
|
|
with Locations((v_front.X + offset_x2, -offset_y2)): Rectangle(dl2o, sz2o, align=(Align.MIN, Align.MIN, Align.CENTER))
|
|
with Locations((v_front.X + offset_x3, -offset_y3)): Rectangle(dl3o, sz3o, align=(Align.MIN, Align.MIN, Align.CENTER))
|
|
with Locations((v_front.X + offset_x4, -offset_y4)): Rectangle(dl4o, sz4o, align=(Align.MIN, Align.MIN, Align.CENTER))
|
|
extrude(amount=-scianka, mode=Mode.SUBTRACT)
|
|
|
|
back = box.faces().sort_by(Axis.Y)[-1]
|
|
# Punkt odniesienia tyłu
|
|
v_back = back.edges().filter_by(Axis.Z).sort_by(Axis.X)[-1].vertices()[0]
|
|
|
|
with BuildSketch(back):
|
|
with Locations((v_back.X - offset_x5, + offset_y5)): Rectangle(dl5o, sz5o, align=(Align.MAX, Align.MAX))
|
|
with Locations((v_back.X - offset_x6 - 12.450, + offset_y6)):
|
|
with GridLocations(12.450, 0, 3, 1): Rectangle(dl6o, sz6o, align=(Align.MAX, Align.MAX))
|
|
with Locations((v_back.X - offset_x7, + offset_y7)): Rectangle(dl7o, sz7o, align=(Align.MAX, Align.MAX))
|
|
extrude(amount=-scianka, mode=Mode.SUBTRACT)
|
|
|
|
# --- ZAGNIEŻDŻONY BUILD PART NA UCHWYTY ---
|
|
# Pobieramy ścianę boczną głównego pudełka jako referencję
|
|
bok = box.faces().sort_by(Axis.X)[-1]
|
|
|
|
# Tworzymy osobną, "wewnętrzną" przestrzeń tylko dla uchwytów
|
|
with BuildPart() as uchwyty_komplet:
|
|
|
|
# 1. Budujemy prawy uchwyt (tak jak w Twoim kodzie)
|
|
with BuildSketch(bok) as szkic_uchwytu:
|
|
with Locations((-przesuniecie_uchwyciku, 0)):
|
|
Rectangle(mini_udl, mini_usz)
|
|
|
|
# Zmienilem nazwe zmiennej z 'u1' na 'baza', żeby nie psuć kontekstu
|
|
baza = extrude(amount=mini_ugr)
|
|
|
|
# Operacje na uchwycie
|
|
u1_face = baza.faces().sort_by(Axis.Y)[0]
|
|
u2_face = baza.faces().sort_by(Axis.X)[-1]
|
|
|
|
with BuildSketch(u1_face):
|
|
with Locations((-2.750, -0.5)):
|
|
Rectangle(wyc_dl, wyc_sz)
|
|
mirror(about=Plane.YZ) # Lustro szkicu wycięcia
|
|
extrude(amount=-wyc_gr, mode=Mode.SUBTRACT)
|
|
|
|
with BuildSketch(u2_face):
|
|
with Locations((-offset_podstawy, 0)):
|
|
Rectangle(pods_dl, pods_sz)
|
|
extrude(amount=pods_gr)
|
|
|
|
# 2. KLUCZOWY MOMENT: Mirror całego uchwytu wewnątrz tej pod-przestrzeni
|
|
# Ponieważ jesteśmy w 'uchwyty_komplet', to polecenie skopiuje wszystko co tu stworzyliśmy
|
|
mirror(about=Plane.YZ)
|
|
|
|
# 3. Dodajemy gotowy zestaw uchwytów (prawy + lewy) do głównego pudełka
|
|
# add(uchwyty_komplet.part)
|
|
# with BuildPart() as zatrzask:
|
|
# z = box.faces().filter_by(Axis.Y).sort_by(Axis.Y)[-2]
|
|
# with BuildSketch(z):
|
|
# Rectangle(20, 20)
|
|
# extrude(amount=50)
|
|
|
|
|
|
# # Wizualizacja
|
|
# show_all()
|
|
show(box, orange)
|