cadquery/monitor/rear_mount.py

71 lines
1.7 KiB
Python
Raw Permalink Normal View History

2022-07-22 21:23:27 +00:00
import cadquery2 as cq
from cadquery2 import exporters
from parameters import *
# Small M3x8 screw
screw_l = 10
screw_shaft = 8
screw_head_h = 2.5
screw_head_radius = 3.5
screw_radius = 1.5
2022-07-23 14:26:55 +00:00
from hinge import hinge_profile_1, hinge_profile_2, hinge_t, hinge_gap, hinge_w
2022-07-22 21:23:27 +00:00
reinforcement_height = 1 + 1 + ti_depth - shell_t
2022-07-24 18:05:31 +00:00
rear_mount_width = width / 2
2022-07-23 13:13:27 +00:00
2022-07-22 21:23:27 +00:00
back_reinforcement_cutout = (
cq.Sketch()
.trapezoid(width / 2 + 1, 15 + 1, 90, mode="a")
.reset()
.vertices()
.fillet(2)
)
back_reinforcement_outer = (
cq.Sketch()
2022-07-23 13:13:27 +00:00
.trapezoid(rear_mount_width, 15 + 2 * shell_t, 90, mode="a")
2022-07-22 21:23:27 +00:00
.reset()
.vertices()
.fillet(2)
)
2022-07-23 13:07:56 +00:00
# FIXME: use counterbore holes function instead
2022-07-22 21:23:27 +00:00
screw_holes = cq.Sketch().rarray(width / 8, 0, 4, 1).circle(screw_radius, mode="a")
screw_countersinks = (
cq.Sketch().rarray(width / 8, 0, 4, 1).circle(screw_head_radius, mode="a")
)
2022-07-23 13:07:56 +00:00
2022-07-22 21:23:27 +00:00
rear_mount = (
# Basic filleted box shape
cq.Workplane("bottom")
.placeSketch(back_reinforcement_outer)
2022-07-24 18:05:31 +00:00
.extrude(screw_head_h + shell_t)
2022-07-22 21:23:27 +00:00
.faces("<Y")
.workplane(centerOption="CenterOfBoundBox")
.placeSketch(screw_holes)
.cutBlind(-1000)
.faces("<Y")
.workplane(centerOption="CenterOfBoundBox")
.placeSketch(screw_countersinks)
.cutBlind(-screw_head_h)
2022-07-23 13:07:56 +00:00
# Hinge integration
.faces(">X")
2022-07-23 19:12:56 +00:00
.workplane(centerOption="CenterOfBoundBox", offset=-(rear_mount_width - 20) / 2)
2022-07-23 13:07:56 +00:00
.transformed(rotate=cq.Vector(0, 0, 90))
2022-07-24 18:05:31 +00:00
.center(-hinge_w / 2, 0)
2022-07-23 19:12:56 +00:00
.tag("hingeplane")
2022-07-23 13:07:56 +00:00
.placeSketch(hinge_profile_1)
.extrude(-hinge_t)
2022-07-23 13:24:08 +00:00
.workplaneFromTagged("hingeplane")
2022-07-23 17:11:30 +00:00
.workplane(offset=-hinge_t - hinge_gap)
2022-07-23 13:13:27 +00:00
.placeSketch(hinge_profile_2)
2022-07-23 19:12:56 +00:00
.extrude(-hinge_t)
)
2022-07-22 21:23:27 +00:00
2022-07-23 19:12:56 +00:00
exporters.export(rear_mount, "rear_mount.stl")