case: fix button gap so that it actually surrounds the button instead of overlaps its edge

This commit is contained in:
2023-12-27 11:02:31 +00:00
parent 769ac04913
commit e4bfcb1d2e

View File

@@ -26,7 +26,7 @@ button_seat_margin_yz = 1.0
button_inset_x = 0.4
button_inset_margin_yz = 5.5
# length of the segment we cut away entirely from the body bordering each button
button_inset_gap = 1.2
button_inset_gap = 1.4
def _makeShell(solid, thickness: float=1, combine=False, **kwargs):
"""
@@ -122,15 +122,27 @@ def button_inset_cutaway(phone, buttons):
return cutout
def button_gap_cutaway(phone, buttons):
"""
cut through the case just around the edge of the buttons, to give them a tab
that more easily flexes.
"""
buttons2d = buttons.faces("<X")
buttons = cq.Workplane("YZ").add(buttons2d) \
.edges().toPending().consolidateWires() \
.toPending().extrude(thickness)
keep = (buttons
.intersect(buttons.translate((0, button_inset_gap, 0)))
.intersect(buttons.translate((0, -button_inset_gap, 0)))
.extrude(thickness)
buttons_with_buffer = cq.Workplane("YZ").add(buttons2d) \
.edges().toPending().offset2D(button_inset_gap) \
.extrude(thickness)
cutout = buttons_with_buffer.cut(buttons)
cutout_top = (cutout
.cut(cutout.translate((0, button_inset_gap, 0)))
.intersect(buttons_with_buffer.translate((0, -2*button_inset_gap, 0)))
)
cutout = buttons.cut(keep)
cutout_bot = (cutout
.cut(cutout.translate((0, -button_inset_gap, 0)))
.intersect(buttons_with_buffer.translate((0, 2*button_inset_gap, 0)))
)
cutout = cutout_top.union(cutout_bot)
return cutout