-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver.py
71 lines (58 loc) · 1.62 KB
/
driver.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
59
60
61
62
63
64
65
66
67
68
69
70
71
import cadquery as cq
import units
import SA
import dummy
import cherry
profiles = {
'dummy': dummy.dummy_profile,
'SA': SA.sa_profile,
'Cherry': cherry.cherry_profile,
}
profile = "Cherry"
keys = [
[
"1R", [1, 1], [1, 2]
],
[
"2R", [2, 1], [2, 1.5]
],
[
"3R", [3, 1], [3, 1.75], [3, 2.25]
],
[
"4R", [4, 1], [4, 2.25], [4, 2.75]
],
[
"5R", [5, 1], [5, 1.25], [5, 1.5], [5, 2], [5, 2.25], [5, 6.5]
],
[
profile
]
]
def draw_keys(generator, keys, writer):
roff = 0
coff = 0
for row in keys:
coff = 0
for key in row:
if not isinstance(key, str):
kobj = generator(key[0], key[1])
writer(key, roff, coff, kobj)
coff += key[1]
else:
offset = 0 if (roff+1 == len(keys)) else -30
halign = 'left' if (roff+1 == len(keys)) else 'right'
kobj = cq.Workplane("XY").text(key, units.CU, 1, halign=halign).translate([offset, -roff * units.UNIT, 0])
writer(key, roff, coff, kobj)
roff += 1
def writer_file(key, row, column, kobj):
if not isinstance(key, str):
fname = "build/SA/%1dR%3dU.step" % (key[0], key[1] * 100)
cq.exporters.export(kobj, fname)
def writer_cqgui(key, row, column, model):
if not isinstance(key, str):
model = model.translate([(column + key[1]/2) * units.UNIT, -row * units.UNIT, 0])
show_object(model)
writer = writer_cqgui
draw_keys(profiles[profile], keys, writer)
#draw_keys(profiles[profile], [[[4, 1.25]]], writer)