You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
263 lines
6.7 KiB
263 lines
6.7 KiB
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
|
|
|
|
pot_diameter = 6.9
|
|
pot_radius = pot_diameter / 2.0
|
|
|
|
switch_diameter = 6.2
|
|
switch_radius = switch_diameter / 2.0
|
|
|
|
gland_diameter = 16.0
|
|
gland_radius = gland_diameter / 2.0
|
|
|
|
screw_length = 10
|
|
top_screw = CounterSunkScrew(
|
|
size="M2.5-0.45",
|
|
fastener_type="iso7046",
|
|
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 = 72.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=-2.6).box(
|
|
box_length + wall_thickness - 2, box_width + wall_thickness - 2, 2, combine="cut"
|
|
)
|
|
|
|
top = top.workplane(offset=-1.7).box(
|
|
box_length - wall_thickness - 0.05, box_width - wall_thickness - 0.05, 2
|
|
)
|
|
|
|
top = (
|
|
top.faces(">Z[4]")
|
|
.rect(
|
|
box_length - 6.5,
|
|
box_width - 6.5,
|
|
forConstruction=True,
|
|
)
|
|
.vertices()
|
|
.cboreHole(2.4, 4.2, 2.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]")
|
|
.workplane(offset=-1)
|
|
.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")
|
|
)
|
|
|
|
top = top.workplane(offset=2).box(10, 20.8, 5.0, combine="cut")
|
|
|
|
top = (
|
|
top.workplane(offset=2).move(10.5 / 2.0, 0).cylinder(5.0, 20.8 / 2.0, combine="cut")
|
|
)
|
|
|
|
top = (
|
|
top.workplane(offset=1)
|
|
.move(-(10.5 / 2.0), 0)
|
|
.cylinder(3.0, 20.8 / 2.0, combine="cut")
|
|
)
|
|
|
|
for i in range(0, 11, 2):
|
|
top = top.workplane(offset=-0.9).move(i, 0).box(1.0, 15, 0.8)
|
|
|
|
for i in range(0, 11, 2):
|
|
top = top.workplane(offset=-0.9).move(-i, 0).box(1.0, 15, 0.8)
|
|
|
|
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 - 6.5, box_width - 6.5)
|
|
.vertices()
|
|
.cylinder(box_height - wall_thickness * 2, 2.5)
|
|
)
|
|
|
|
bottom = (
|
|
bottom.workplane(offset=(box_height / 2) + 3.6)
|
|
.rect(box_length - 6.5, box_width - 6.5)
|
|
.vertices()
|
|
.threadedHole(top_screw, 10, simple=screw_simple, fit="Close", counterSunk=False)
|
|
)
|
|
|
|
battery_holder_offset_factor = 6.5
|
|
|
|
bottom = (
|
|
bottom.workplane(offset=-(box_height / 2.0) + 8.9)
|
|
.move(box_length / 2.0 - wall_thickness * battery_holder_offset_factor, 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 * battery_holder_offset_factor) - 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 * battery_holder_offset_factor) - 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 * battery_holder_offset_factor) - 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 * battery_holder_offset_factor) - 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)
|
|
)
|
|
|
|
pot_holes = (
|
|
Workplane("YZ")
|
|
.workplane(offset=-(box_length / 2.0))
|
|
.move(12, 0)
|
|
.cylinder(wall_thickness * 2, pot_radius)
|
|
.workplane()
|
|
.move(-12, 0)
|
|
.cylinder(wall_thickness * 2, pot_radius)
|
|
)
|
|
|
|
bottom = bottom.cut(pot_holes)
|
|
|
|
|
|
switch_hole = (
|
|
Workplane("XZ")
|
|
.workplane(offset=-(box_width / 2.0))
|
|
.move(-(box_length / 2.0) + 30, 0)
|
|
.cylinder(wall_thickness * 2, switch_radius)
|
|
)
|
|
|
|
bottom = bottom.cut(switch_hole)
|
|
|
|
gland_hole = (
|
|
Workplane("XZ")
|
|
.workplane(offset=(box_width / 2.0))
|
|
.move(-(box_length / 2.0) + 30, 0)
|
|
.cylinder(wall_thickness * 2, gland_radius)
|
|
)
|
|
|
|
bottom = bottom.cut(gland_hole)
|
|
|
|
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
|
|
|