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_s = 7.5 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_s)) .arc((0, hinge_s), (hinge_s / 2, 1.5 * hinge_s), (hinge_s, hinge_s)) .segment((hinge_s, 0)) .close() .arc((hinge_s / 2, hinge_s), screw_radius, 0, 360) .assemble() ) hinge_profile_2 = ( cq.Sketch() .segment((0, 0), (0, hinge_s)) .arc((0, hinge_s), (hinge_s / 2, 1.5 * hinge_s), (hinge_s, hinge_s)) .segment((hinge_s, 0)) .close() .arc((hinge_s / 2, hinge_s), 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")