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 = False # 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 hole_diameter = 3.44 hole_radius = hole_diameter / 2.0 box_width = 65.0 box_height = 30.0 box_length = 100.0 wall_thickness = 2.0 battery_holder_width = 62.67 battery_holder_length = 57.36 battery_holder_height = 15.83 battery_holder_hole_dist = ( 14.76 # distance between the centers of the countersunk holes ) battery_holer_hole_dist_from_side = ( 8.39 # distance from side to middle of the first hole ) 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) ) 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) - 10) .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) + 3.0) .rect(box_length - 5.5, box_width - 5.5) .vertices() .threadedHole(top_screw, 10, 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(bottom) except NameError: pass