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.

114 lines
3.3 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
pole_height = 24.5
pole_dist = 10
screw_length = 10 # FIXME need different ones for different holes
top_screw = ButtonHeadScrew(
size="M3-0.5", fastener_type="iso7380_1", length=screw_length * MM, simple=screw_simple
)
gland_diameter = 15
barrel_diameter = 11
# digikey perfboard
# It's the distance to the *middle* of the hole
breadboard_height = 81
breadboard_width = 50.8
bb_hole_dist_from_top = 5.37
bb_hole_dist_from_side = 25.23
bb_hole_diameter = 2.76
# buck converter
bc_height = 43.18
bc_width = 31.16
bc_hole_dist_from_top = 6.44
bc_hole_dist_from_side = 2.21 # distance to middle of hole as before, also it's the distance from the closer side
bc_hole_diameter = 4.18
# large buck converter
lbc_height = 57.8
lbc_width = 57.8
lbc_hole_dist_from_top = 4.5
lbc_hole_dist_from_side = 25.8
lbc_hole_diameter = 6.83
wall_thickness = 3
box_height = 115 + wall_thickness
box_width = 157 + wall_thickness
box_thickness = 25
lower_box = Workplane()
def make_component_holder(result, pole_dist, pole_height, box_width, box_height, wall_thickness, x_offset=0, y_offset=0):
return (
result.workplane(offset=(pole_height/2)-wall_thickness).move(x_offset, y_offset)
.rect(
box_height - wall_thickness - pole_dist, box_width - wall_thickness - pole_dist
)
.vertices()
.cylinder(pole_height, 3)
.workplane(offset=(pole_height-wall_thickness+1.5)).move(x_offset, y_offset)
.rect(
box_height - wall_thickness - pole_dist, box_width - wall_thickness - pole_dist
)
.vertices()
.threadedHole(top_screw, pole_height*0.4, simple=screw_simple)
)
lower_box = (
lower_box.box(box_height, box_width, box_thickness)
.workplane(offset=wall_thickness)
.box(
box_height - wall_thickness,
box_width - wall_thickness,
box_thickness,
combine="cut",
)
)
lower_box = make_component_holder(lower_box,
pole_dist,
pole_height,
box_width,
box_height,
wall_thickness,
)
lower_box = make_component_holder(lower_box,
pole_dist,
10,
50,
30,
wall_thickness,
x_offset=10,
y_offset=15)
cq.exporters.export(lower_box, "/home/deck/model_files/fan_control_box_lower.step")
try:
show_object(lower_box)
except NameError:
pass