Skip to content

Instantly share code, notes, and snippets.

@crides
Created October 1, 2022 01:27
Show Gist options
  • Save crides/df2c63a1284abdd59b00e1734d001646 to your computer and use it in GitHub Desktop.
Save crides/df2c63a1284abdd59b00e1734d001646 to your computer and use it in GitHub Desktop.
import cadquery as cq
slt_dist = (11.85 + 10.35) / 2
boss_len = (11.85 - 10.35) / 2
boss_d = 0.86
def make_slot():
slt_h, slt_d, slt_g, slt_t = 1.2, boss_d, 0.65, boss_len
slt_w = 1.5 # guessed
return (cq.Workplane("XZ").sketch()
.push([(0, -slt_h / 2)]).rect(slt_w, slt_h).rect(slt_g, 10, mode="s")
.push([(0, -slt_d / 2)]).circle(slt_d / 2, mode="s")
.push([(0, -slt_d / 4)]).rect(slt_d, slt_d / 2, mode="s")
.reset().vertices("<Y exc >X exc <X").chamfer(0.1)
.finalize().extrude(slt_t / 2, both=True))
def make_slide(b):
sld_w, sld_h, sld_t = 0.9, boss_d, boss_len
return (cq.Workplane("XY")
.workplane(-sld_t-0.5)
.box(sld_w, sld_t, sld_h, centered=(False, True, False))
.faces(f">X or {'<' if b else '>'}Y").shell(0.3, kind="intersection")
)
cap = (cq.Workplane().sketch().rect(16.5, 16.5).vertices().fillet(1).finalize().extrude(1).faces("<Z").shell(-0.5).edges(">Z").fillet(0.2)
.faces("<Z[1]").workplane()
.transformed(offset=(-5, 0, 0)).rarray(1, slt_dist, 1, 2, center=True)
.each(lambda p: make_slot().translate(p).val())
.transformed(offset=(10.1, 0, 0)).rarray(1, slt_dist, 1, 2, center=True)
.each(lambda p: make_slide(p.y > 0).translate(p).val()))
show_object(cap)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment