Took a look and here is my version with a few suggestions, feel free to use any part or all parts as you see fit:
from build123d import (
BuildPart,
BuildSketch,
BuildLine,
Box,
Plane,
Polyline,
Location,
Locations,
Axis,
Rot,
mirror,
make_face,
extrude,
fillet,
chamfer,
)
COVER_WIDTH = 62
COVER_DEPTH = 37
COVER_HEIGHT = 2
POLY_WIDTH = 25
FILLET_SIZE = 2
BOX_WIDTH = 6
USE_TABS = True ## False
with BuildPart() as cover:
with BuildSketch() as s:
Rectangle(COVER_WIDTH, COVER_DEPTH)
extrude(amount=COVER_HEIGHT) # position control, box is now NOT half below XY
split(bisect_by=Plane.YZ) # keep only half
with BuildPart(mode=Mode.PRIVATE) as box_p: # construct private box on the origin and transform later
with BuildSketch() as s:
Rectangle(BOX_WIDTH, 6)
extrude(amount=8)
if USE_TABS: #placing tabs is easier because the selector is simpler and more robust
fc2 = faces().filter_by(Axis.X)[-1] #get face center of small edge box
plane = Plane(fc2).rotated((0, -5, 0)) #rotate -5 degrees about local y-axis
with BuildSketch(plane) as tab_sk2:
Rectangle(4, 2, align=(Align.CENTER, Align.MAX)) #align top edge to y-axis
extrude(until=Until.PREVIOUS) # used extrude-until so that dimensions are not needed
mirror(about=Plane.YZ) #leverage local centerline symmetry to mirror the tab
loc = Location(
(COVER_WIDTH / 2 - 8 - BOX_WIDTH / 2, -COVER_DEPTH / 2 - BOX_WIDTH / 2, 0)
)
with Locations(loc):
add(box_p.part) #move the box into position
plane = Plane.XZ.offset(-COVER_DEPTH / 2)
with BuildSketch(plane) as poly_sk:
with BuildLine(Location((COVER_WIDTH / 2 - POLY_WIDTH, COVER_HEIGHT))) as line:
Polyline((0, 0), (POLY_WIDTH, 0), (20, 5), (5, 5), (0, 0))
make_face()
extrude(amount=COVER_HEIGHT)
edgs = cover.part.edges().filter_by(Axis.X).group_by(Axis.Y)[2][0]
fillet(edgs, FILLET_SIZE)
edgs = cover.part.edges().filter_by(Axis.X).group_by(Axis.Y)[1][1]
fillet(edgs, FILLET_SIZE)
#eliminated one fillet with later mirror operation
if USE_TABS:
fc = poly_sk.sketch.face().center() # get trapezoid face center
plane = Plane(
origin=(fc.X, fc.Y, COVER_HEIGHT + 2), x_dir=(-1, 0, 0), z_dir=(0, 1, 0)
) # manually construct a plane with some of the face center coordinates
with BuildSketch(plane.rotated((5, 0, 0))) as tab_sk: # create sketch on plane rotated about local y-axis
Rectangle(4, 2, align=(Align.CENTER, Align.MAX))
extrude(until=Until.PREVIOUS)
mirror(about=Plane.YZ) #leverage CL symmetry to reduce code-duplication
if __name__ in ['__main__', 'temp']:
show_object(cover)
The only caveat here is that extrude-until can be sometimes a little less stable than providing a dimension manually. In this case it seems to work very well, but just be advised. One could easily substitute a dimension manually in this case too.
Took a look and here is my version with a few suggestions, feel free to use any part or all parts as you see fit:
The only caveat here is that extrude-until can be sometimes a little less stable than providing a dimension manually. In this case it seems to work very well, but just be advised. One could easily substitute a dimension manually in this case too.