from cadquery import exporters from cq_warehouse.extensions import Workplane from cq_warehouse.fastener import * from cq_warehouse.thread import * from cqmore.curve import archimedeanSpiral, circle from cqmore.polygon import regularPolygon, star from cqmore.polyhedron import polarZonohedra, Polyhedron, superellipsoid from svg_path import addSvgPath from svgpathtools import svg2paths import cadquery as cq import cqmore from math import ceil, floor Workplane = cqmore.extend(Workplane) Workplane.addSvgPath = addSvgPath screw_simple = True # Controls whether to not actually make the screw threads, saves time running it for testing screw_length = 10 top_screw = ButtonHeadScrew( size="M3-0.5", fastener_type="iso7380_1", length=screw_length * MM, simple=screw_simple, ) x_board_size = 36.07 y_board_size = 28.75 hole_dist_x = 22.76 hole_dist_y = ( 31.29 - 0.15 ) # Need to subtract a bit because it's slightly off, but the original number is correct hole_diameter = 3.44 hole_radius = hole_diameter / 2.0 box_width = 65.0 box_height = 30.0 box_length = 120.0 wall_thickness = 2.0 battery_holder_width = 62.67 battery_holder_length = 57.36 battery_holder_height = 15.83 battery_holder_hole_dist = ( 15.57 # distance between the centers of the countersunk holes ) battery_holder_slot_dist_from_holes = ( 25.4 # How far away the fitting slot is from the screw holes ) battery_holder_slot_length = 52.0 battery_holder_slot_width = 2.1 battery_holder_screw_radius = 6.37 / 2.0 result = ( Workplane() .box(box_length, box_width, box_height) .box( box_length - wall_thickness, box_width - wall_thickness, box_height - wall_thickness, combine="cut", ) ) top = result.workplane(offset=(box_height / 2) - 2).split(keepTop=True) top = top.workplane(offset=-1.5).box( box_length + wall_thickness, box_width + wall_thickness, 2, combine="cut" ) top = top.workplane(offset=-0.8).box( box_length - wall_thickness - 0.05, box_width - wall_thickness - 0.05, 1 ) top = ( top.faces(">Z[3]") .rect( box_length - 5.5, box_width - 5.5, forConstruction=True, ) .vertices() .cboreHole(2.0, 3.0, 1.1) ) speaker_length = ( 30 - 2.75 - 15 - 2 ) # 15 is half of the length, 2 is for the cylinders being cut speaker_width = 14.5 - 2.75 speaker_thickness = 5 top = top.faces(">Z[0]").box( speaker_length, speaker_width, speaker_thickness, combine="cut" ) top = ( top.workplane() .move(speaker_length / 2.0, 0) .cylinder(5, speaker_width / 2.0, combine="cut") ) top = ( top.workplane() .move(-(speaker_length / 2.0), 0) .cylinder(5, speaker_width / 2.0, combine="cut") ) bottom = result.workplane(offset=(box_height / 2) - 2).split(keepBottom=True) bottom = bottom.workplane(offset=box_height + 5).box( box_length - 1, box_width - 1, box_height, combine="cut" ) bottom = ( bottom.workplane(offset=(box_height / 2) - 9) .rect(box_length - 5.5, box_width - 5.5) .vertices() .cylinder(box_height - wall_thickness * 1.5, 2.5) ) bottom = ( bottom.workplane(offset=(box_height / 2) + 4.0) .rect(box_length - 5.5, box_width - 5.5) .vertices() .threadedHole(top_screw, 10, simple=screw_simple, fit="Close", counterSunk=False) ) bottom = ( bottom.workplane(offset=-(box_height / 2.0) + 8.9) .move(box_length / 2.0 - wall_thickness * 4, 0) .box(battery_holder_slot_width, battery_holder_slot_length, 4.0) ) bottom = ( bottom.workplane(offset=-(box_height / 2.0) + 9.0) .move( (box_length / 2.0 - wall_thickness * 4) - 24.0, -(battery_holder_slot_length / 6.5), ) .vLine(battery_holder_hole_dist) .vertices() .cylinder(4, battery_holder_screw_radius) .workplane(offset=-(box_height / 2.0) + 11.10) .move( (box_length / 2.0 - wall_thickness * 4) - 24.0, -(battery_holder_slot_length / 6.5), ) .vLine(battery_holder_hole_dist) .vertices() .threadedHole(top_screw, 2.0, simple=screw_simple, fit="Close", counterSunk=False) ) bottom = ( bottom.workplane(offset=-(box_height / 2.0) + 9.0) .move( (box_length / 2.0 - wall_thickness * 4) - 24.0, (battery_holder_hole_dist * 2) - 8, ) .vLine(-(battery_holder_hole_dist * 3)) .vertices() .cylinder(4, battery_holder_screw_radius) .workplane(offset=-(box_height / 2.0) + 11.10) .move( (box_length / 2.0 - wall_thickness * 4) - 24.0, (battery_holder_hole_dist * 2) - 8, ) .vLine(-(battery_holder_hole_dist * 3)) .vertices() .threadedHole(top_screw, 2.0, simple=screw_simple, fit="Close", counterSunk=False) ) bottom = ( bottom.workplane(offset=-(box_height / 2.0) + 9.0) .move( -(box_length / 4.0), 0, ) .rect(hole_dist_x, hole_dist_y) .vertices() .cylinder(4, hole_radius + 1) .workplane(offset=-(box_height / 2.0) + 11.10) .move( -(box_length / 4.0), 0, ) .rect(hole_dist_x, hole_dist_y) .vertices() .threadedHole(top_screw, 2.0, simple=screw_simple, fit="Close", counterSunk=False) ) cq.exporters.export(bottom, "/home/deck/model_files/carlon_probe_amp_enclosure_box.stl") cq.exporters.export(top, "/home/deck/model_files/carlon_probe_amp_enclosure_lid.stl") try: show_object(top) except NameError: pass