-
Notifications
You must be signed in to change notification settings - Fork 1
/
hinge.py
executable file
·58 lines (50 loc) · 2.49 KB
/
hinge.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/python3
import math, solid
from solidff import *
from KicadModTree import Pad, Text, Line, Arc, RectLine, Circle
from lib import kicad_fp, m2_hole, half_total_space, washer_outer, nut_outer, nut_outer_safe
ridge_thick = 2
mount_thick = 2
nylon = 1.05
mount_offset = 0
gap = ridge_thick + nylon * 2 + ridge_thick
cy_thick = 1.25
def top():
hring = ring(od=washer_outer, id=m2_hole, center=True, hole=True).y(half_total_space)
stick = hring ** q(nut_outer_safe, mount_thick, ridge_thick).z(-cy_thick)
return stick.r(90, 0, 0)
def hinge1():
hring = ring(od=washer_outer, id=m2_hole, center=True, hole=True).y(half_total_space)
stick = hring ** q(nut_outer_safe, mount_thick, ridge_thick).z(-cy_thick)
stick_sketch = solid.projection(True)(stick)
top = ring(id=nut_outer, w=cy_thick, h=10, extra=False, hole=True).z(mount_thick) + ring(id=nut_outer, w=cy_thick, h=mount_thick)
bottom = ring(id=m2_hole, od=nut_outer, h=mount_thick, hole=True)
mask = stick_sketch.e(10).z(-5) * (q(20, half_total_space, 10, center="xz") + q(20, 20, ridge_thick, center="xz"))
mask = mask.r(90, 0, 0)
return (top.x(nut_outer_safe) + stick.r(90, 0, 0)) * mask + bottom.x(nut_outer_safe)
def hinge2():
bottom = q(nut_outer_safe, gap, mount_thick, center="y").c("royalblue") - cy(d=m2_hole, h=mount_thick).x(nut_outer_safe / 2)
return top().y(-gap / 2) + top().y(gap / 2) + bottom
def hinge1_fp():
y = (gap + ridge_thick) / 2
arc_top, arc_bot = (nut_outer_safe, -nut_outer_safe / 2), (nut_outer_safe, nut_outer_safe / 2)
nut_pos = (nut_outer_safe, 0)
return [
RectLine(start=(0, cy_thick), end=(nut_outer_safe - nut_outer / 2, -cy_thick), layer='Cmts.User'),
Pad(type=Pad.TYPE_NPTH, shape=Pad.SHAPE_CIRCLE,
at=nut_pos, size=(m2_hole, m2_hole), drill=m2_hole, layers=Pad.LAYERS_NPTH),
Circle(center=nut_pos, radius=nut_outer / 2, layer='Cmts.User'),
Arc(start=arc_top, center=nut_pos, end=arc_bot, layer='Cmts.User'),
Line(start=arc_top, end=arc_bot, layer='Cmts.User'),
]
def hinge2_fp():
y = (gap + ridge_thick) / 2
return [
RectLine(start=(0, y), end=(nut_outer_safe, -y), layer='Cmts.User'),
Pad(type=Pad.TYPE_NPTH, shape=Pad.SHAPE_CIRCLE,
at=(nut_outer_safe / 2, 0), size=(m2_hole, m2_hole), drill=m2_hole, layers=Pad.LAYERS_NPTH),
]
dump(hinge1, "hinge1.scad")
dump(hinge2, "hinge2.scad")
kicad_fp("hinge1", hinge1_fp(), dir="fusion")
kicad_fp("hinge2", hinge2_fp(), dir="fusion")