cadquery/monitor/hinge.py

48 lines
1.0 KiB
Python

import cadquery2 as cq
from cadquery2 import exporters
from parameters import *
# M3x20 screw
screw_l = 22
screw_shaft = 20
screw_head_h = 2.5
screw_head_radius = 3.5
screw_radius = 1.5
hinge_w = 7.5
hinge_h = 15
hinge_t = ti_depth - 1
hinge_gap = screw_shaft - 2 * hinge_t
# The side of the screw head
hinge_profile_1 = (
cq.Sketch()
.segment((0, 0), (0, hinge_h))
.arc((0, hinge_h), (hinge_w / 2, hinge_h + hinge_w / 2), (hinge_w, hinge_h))
.segment((hinge_w, 0))
.close()
.arc((hinge_w / 2, hinge_h), screw_radius, 0, 360)
.assemble()
)
hinge_profile_2 = (
cq.Sketch()
.segment((0, 0), (0, hinge_h))
.arc((0, hinge_h), (hinge_w / 2, hinge_h + hinge_w / 2), (hinge_w, hinge_h))
.segment((hinge_w, 0))
.close()
.arc((hinge_w / 2, hinge_h), ti_radius, 0, 360)
.assemble()
)
hinge = (
cq.Workplane("bottom")
.placeSketch(hinge_profile_1)
.extrude(hinge_t)
.workplane(offset=hinge_gap)
.placeSketch(hinge_profile_2)
.extrude(hinge_t)
)
# exporters.export(hinge, "hinge.stl")