def test_groove(self): # path should be a wire in XY plane at Z=0 # the path the cutting tool will follow cq.Workplane.mk_groove = groovy.mk_groove # add our vgroove function to the Workplane class cutter_path = cq.Workplane("XY").rect(150, 150, centered=True).extrude( 1).edges("|Z").fillet(10).faces("-Z").wires().val() demo_block = cq.Workplane("XY").rect( 200, 200, centered=True).extrude(-200).edges("|Z").fillet(3) asy = cadquery.Assembly() depth = 4 # vslot ring_cs = 1 # o-ring cross-section diameter co = {"centerOption": "CenterOfBoundBox"} demo_block = demo_block.faces(">Z").workplane( **co).add(cutter_path).wires().toPending().mk_groove(vdepth=depth) demo_block = demo_block.faces("<Z").workplane(**co).sketch().rect( 50, 50).vertices().fillet(10).finalize().mk_groove(vdepth=depth) demo_block = demo_block.faces("<X").workplane(**co).sketch().rarray( 75, 75, 2, 2).circle(25).finalize().mk_groove(vdepth=depth) min_inner_rad = 3 * ring_cs gland_width = groovy.get_gland_width(ring_cs=ring_cs) mid_rad = min_inner_rad + gland_width / 2 demo_block = demo_block.faces(">X").workplane(**co).sketch() demo_block = demo_block.push([(75 / 2, 75 / 2) ]).rect(50, 50, angle=31).reset() demo_block = demo_block.push([(-75 / 2, -75 / 2) ]).rect(50, 50, angle=7).reset() demo_block = demo_block.push([(75 / 2, -75 / 2) ]).rect(50, 50, angle=23).reset() demo_block = demo_block.push([(-75 / 2, 75 / 2) ]).rect(50, 50, angle=-17).reset() demo_block = demo_block.vertices().fillet( mid_rad).finalize().mk_groove(ring_cs=ring_cs, hardware=asy) demo_block = demo_block.faces("<Y").workplane(**co).mk_groove( ring_cs=ring_cs, follow_pending_wires=False, ring_id=90, gland_x=70, gland_y=100, hardware=asy) demo_block = demo_block.faces(">Y").workplane(**co).mk_groove( ring_cs=ring_cs, follow_pending_wires=False, ring_id=111, gland_x=80, gland_y=100, hardware=asy) tmpdirname = tempfile.mkdtemp() outfile = pathlib.Path(tmpdirname) / "groove.step" asy.add(demo_block) asy.save(str(outfile)) # save step
def mk_dovetail_ogroove(cutter_path, entry_point): """makes a very special oring grove""" # dims from https://web.archive.org/web/20210311103938/https://eicac.co.uk/O-Ring-Grooves for a 4mm oring grove_width = 3.10 # from sharp edges grove_depth = 3.20 bottom_radius = 0.8 # R1 top_radius = 0.25 # r2, the important one r = top_radius # industry standard? dovetail_angle = 66 # use socahtoa to tell us how to draw the sketch for the dovetail design a = grove_depth / math.sin(math.radians(dovetail_angle)) b = (r + r / (math.sin(math.radians(90 - dovetail_angle)))) / math.tan( math.radians(dovetail_angle)) p0 = (0, 0) p1 = (grove_width / 2, 0) p2 = (grove_width / 2 + a, -grove_depth) p3 = (0, -grove_depth) p1 = (grove_width / 2 + b, 0) p2 = (grove_width / 2 + b, -r) p3 = (grove_width / 2 + b - r * math.sin(math.radians(dovetail_angle)), -r - r * math.cos(math.radians(dovetail_angle))) p4 = (grove_width / 2 + a, -grove_depth) p5 = (0, -grove_depth) cutter_sketch_half = cq.Workplane("XZ").polyline([p0, p1, p2, p3, p4, p5]).close() cutter_sketch_revolved = cutter_sketch_half.revolve() ring_sketch = cq.Workplane("XZ").moveTo(p2[0], p2[1]).circle(r) ring = ring_sketch.revolve() cutter = cutter_sketch_revolved.cut(ring).faces("-Z").fillet(bottom_radius) # make shape for cutter entry/exit splitted = cutter.faces("-Z").workplane(-bottom_radius).split( keepTop=True, keepBottom=True) top = cq.Workplane(splitted.vals()[1]).translate([0, 0, grove_depth]) bot = cq.Workplane(splitted.vals()[0]).faces( "+Z").wires().toPending().extrude(grove_depth) cutter_entry_shape = bot.union(top) cutter_split = cutter.split(keepTop=True) cutter_crosssection = cutter_split.faces( "+Y") # TODO do this more generally cutter_crosssection_shift = cutter_crosssection.translate(entry_point) to_sweep = cutter_crosssection_shift.wires().toPending() sweep_result = to_sweep.sweep(cutter_path, combine=False) return sweep_result, cutter_entry_shape
def test_passthrough(self): cq.Workplane.passthrough = passthrough.make_cut mwp = cq.Workplane("XZ").circle(80.0).extrude(20) mwp = mwp.translate((99, 99, 99)) mwp = mwp.faces("<Y").workplane(centerOption="CenterOfBoundBox") mwp = mwp.rarray(30, 20, 2, 2).passthrough(rows=8, angle=80, kind="C") tmpdirname = tempfile.mkdtemp() outfile = pathlib.Path(tmpdirname) / "passthrough.step" u.export_step(mwp, outfile)
def test_dovetail(self): # path should be a wire in XY plane at Z=0 # the path the cutting tool will follow cutter_path = cq.Workplane("XY").rect(150, 150, centered=True).extrude( 1).edges("|Z").fillet(10).faces("-Z").wires() demo_block = cq.Workplane("XY").rect( 200, 200, centered=True).extrude(-5).edges("|Z").fillet(3) entry_point = [75, 0, 0] # point along the path where the tool enters/exits sweep_result, cutter_entry_shape = groovy.mk_dovetail_ogroove( cutter_path, entry_point) result = demo_block.cut(sweep_result) result = result.cut(cutter_entry_shape.translate(entry_point)) osalad = result.findSolid() tmpdirname = tempfile.mkdtemp() outfile = pathlib.Path(tmpdirname) / "dovetail.step" u.export_step(osalad, outfile)
def test_oringer(self): """testing for an o-ring based pcb passthrough""" cq.Workplane.make_oringer = passthrough.make_oringer wall_thickness = 12 pcb_scr_head_d_safe = 6 n_header_pins = 50 header_length = n_header_pins / 2 * 2.54 + 7.62 # n*0.1 + 0.3 inches support_block_width = 7 pt_pcb_width = 2 * (support_block_width / 2 + pcb_scr_head_d_safe / 2) + header_length outer_depth = 8.89 + 0.381 # 0.35 + 0.15 inches inner_depth = 8.89 + 0.381 # 0.35 + 0.15 inches mwp = cq.Workplane("ZX").circle(80.0).extrude(wall_thickness) mwp = mwp.translate((99, 99, 99)) mwp = mwp.faces("<Y").workplane(centerOption="CenterOfBoundBox") hardware = cadquery.Assembly(name="passthrough hardware") pcb = cadquery.Assembly(name="passthrough pcbs") oringer = cadquery.Assembly(name="passthroughs") mwp = mwp.rarray(1, 40, 1, 3).make_oringer(board_width=pt_pcb_width, board_inner_depth=inner_depth, board_outer_depth=outer_depth, pt_asy=oringer, pcb_asy=pcb, hw_asy=hardware) final = cadquery.Assembly(name="passthrough testing") final.add(mwp, name="base part") final.add(hardware) final.add(pcb) final.add(oringer) tmpdirname = tempfile.mkdtemp() outfile = pathlib.Path(tmpdirname) / "passthrough.step" final.save(str(outfile))
subac.extend(ablockB.vals()) # assembly.extend(suba) # now duplicate the subassembly to its correct final locations (the 4 rows) assembly.extend([x.translate((3 * gap4 / 2, 0, 0)) for x in subac]) # noqa: E201 assembly.extend([x.translate((gap4 / 2, 0, 0)) for x in suba]) # noqa: E201 assembly.extend([x.translate((-gap4 / 2, 0, 0)) for x in suba]) # noqa assembly.extend([x.translate((-3 * gap4 / 2, 0, 0)) for x in subab]) # now for the windblocking plate: wb_plate_dims = [154, 17.4, 2] mount_y_offset = -0.7 mount_x_spacing = 19 mount_d = tb.c.std_screw_threads["m3"]["close_r"] * 2 wp = cq.Workplane("XY") wb = wp.box(wb_plate_dims[0], wb_plate_dims[1], wb_plate_dims[2], centered=[True, True, True]) wb = wb.faces(">Z").workplane(centerOption="CenterOfBoundBox").center(0, mount_y_offset).rarray(mount_x_spacing, 1, 2, 1).hole(mount_d) wb = wb.rotate((0, 0, 0), (1, 0, 0), 90) position_magic_a = 87.5 # offset from center of chamber position_magic_b = 0.5 # height off the chamber floor wb = wb.translate((0, position_magic_a, wb_plate_dims[1] / 2 + position_magic_b)) wb = wb.rotate((0, 0, 0), (0, 0, 1), 90) wb1 = to_holder(wb, chamber_floor) wb2 = wb1.mirror(mirrorPlane="ZY") assembly.extend(wb1.vals()) assembly.extend(wb2.vals()) # workplane for mux stuff wp = cq.Workplane("XY")
cutter_split = cutter.split(keepTop=True) cutter_crosssection = cutter_split.faces('+Y') #TODO do this more generally cutter_crosssection_shift = cutter_crosssection.translate(entry_point) to_sweep = cutter_crosssection_shift.wires().toPending() sweep_result = to_sweep.sweep(cutter_path, combine=False) return sweep_result, cutter_entry_shape if ("show_object" in locals()) or (__name__ == "__main__"): # path should be a wire in XY plane at Z=0 # the path the cutting tool will follow cutter_path = ( cq.Workplane("XY") .rect(150,150,centered=True) .extrude(1) .edges('|Z') .fillet(10) .faces('-Z') .wires() ) demo_block = ( cq.Workplane("XY") .rect(200,200,centered=True) .extrude(-5) .edges('|Z') .fillet(3) ) entry_point = [75,0,0] # point along the path where the tool enters/exits # vslot demo