build123d_orange/orange.py

85 lines
2.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)))
dlugosc = 112.80
szerokosc = 87.80
wysokosc = 54
scianka = 3
# 1 otworek
dl1o = 17.84
sz1o = 11.68
offset_x1 = 8.931
offset_y1 = 18.295
# 2 otworek
dl2o = 24.103
sz2o = 22.007
offset_x2 = 27.894
offset_y2 = 19.047
# 3 otworek
dl3o = 6.20
sz3o = 8.40
offset_x3 = 55.740
offset_y3 = 14.770
# 4 otworek
dl4o = 26.577
sz4o = 19.737
offset_x4 = 70.481
offset_y4 = 23.208
# 5 otworek
dl5o = 15.400
sz5o = 20.400
offset_x5 = 8.910
offset_y5 = 16.720
# with Locations((front_left_edge_vertex.X + 0, 0))
with BuildPart() as box:
with BuildSketch() as s1:
Rectangle(dlugosc, szerokosc)
extrude(amount=wysokosc)
offset(amount=-scianka, openings=box.faces().sort_by(Axis.Z)[-1])
front = box.faces().sort_by(Axis.Y)[0]
front_left_edge_vertex = box.faces().sort_by(Axis.Y)[0].edges().filter_by(Axis.Z).sort_by(Axis.X)[0].vertices()[0]
with BuildSketch(front) as s2:
with Locations((front_left_edge_vertex.X + offset_x1, -offset_y1)):
Rectangle(dl1o, sz1o, align=(Align.MIN, Align.MIN, Align.CENTER))
extrude(amount=-scianka, mode=Mode.SUBTRACT)
with BuildSketch(front) as s3:
with Locations((front_left_edge_vertex.X + offset_x2, -offset_y2)):
Rectangle(dl2o, sz2o, align=(Align.MIN, Align.MIN, Align.CENTER))
extrude(amount=-scianka, mode=Mode.SUBTRACT)
with BuildSketch(front) as s4:
with Locations((front_left_edge_vertex.X + offset_x3, -offset_y3)):
Rectangle(dl3o, sz3o, align=(Align.MIN, Align.MIN, Align.CENTER))
extrude(amount=-scianka, mode=Mode.SUBTRACT)
with BuildSketch(front) as s5:
with Locations((front_left_edge_vertex.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]
back_left_edge_vertex = box.faces().sort_by(Axis.Y)[-1].edges().filter_by(Axis.Z).sort_by(Axis.X)[-1].vertices()[0]
with BuildSketch(back) as s6:
with Locations((back_left_edge_vertex.X - offset_x5, +offset_y5)):
Rectangle(dl5o, sz5o, align=(Align.MAX, Align.MAX))
extrude(amount=-scianka, mode=Mode.SUBTRACT)
# show_all()
show(box, orange, s6)