Misc-3D-Prints/Electronics and Digital Fabrication/lulzbot-mini-camera/camera-bracket.py

61 lines
1.6 KiB
Python

#!/usr/bin/env python3
import cadquery as cq
from cadquery import exporters
camera_width = 43.4 + 0.5
camera_height = 6
cutout_width = 18 - 0.5
cutout_length = 21.5 - 0.5
cutout_straight_length = 16 - 0.5
bracket_width = cutout_length
bracket_thickness = 3
bolt_hole_diameter = 3.4
bolt_hole_spacing = 10
bolt_offset_y = 9.35 # derived from bolt spacing from edge
bolt_tab_width = bolt_hole_diameter * 3
corner_radius = 1
result = (
cq
.Workplane("front")
.box(camera_width + bracket_thickness * 2, bracket_width, camera_height + bracket_thickness)
.faces(">Y")
.workplane()
.move(yDist=-bracket_thickness / 2)
.rect(camera_width, camera_height, True)
.cutThruAll()
.faces("<Z[1]")
.edges("<Y")
.workplane(centerOption="CenterOfMass")
.transformed(rotate=(0, 0, 180))
.center(-cutout_width/2, 0)
.lineTo(0, cutout_straight_length)
.threePointArc((cutout_width / 2, cutout_length), (cutout_width, cutout_straight_length))
.lineTo(cutout_width, 0)
.close()
.extrude(camera_height)
.faces(">X")
.vertices("<Y and <Z")
.workplane(centerOption="CenterOfMass")
.rect(bracket_width, bracket_thickness, centered=False)
.extrude(bolt_tab_width)
.faces("<Z[1]")
.edges("<X and <Y")
.workplane(centerOption="CenterOfMass")
.center(bolt_tab_width / 2, -bolt_offset_y)
.rarray(1, bolt_hole_spacing, 1, 2)
.hole(bolt_hole_diameter)
.edges("|Z or >Z").fillet(corner_radius)
.faces(">Z[1]").edges(">X or <X or >Y").fillet(corner_radius)
)
exporters.export(result, 'camera-bracket.stl')