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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
import os
import copy
import importlib
from generate_configuration import *
ENGINE = 'solid'
# ENGINE = 'cadquery'
base = shape_config
config_options = [
{
'name': '{}x{}', 'vars': ['nrows', 'ncols'],
'vals':[(4, 5), (5, 6)],
# 'vals': [(4, 5), (4, 6), (5, 6), (6, 6)],
},
{
'name': '{}PLT', 'vars': ['plate_style'],
'vals': ['NOTCH', 'HS_NOTCH'],
# 'vals': ['NUB', 'NOTCH', 'HS_NUB', 'HS_NOTCH'],
},
{
'name': '{}TMB', 'vars': ['thumb_style'],
'vals': ['DEFAULT', 'MINIDOX'],
'val_names': ['DEF', 'MDOX']
# 'vals': ['DEFAULT', 'MINI', 'CARBONFET', 'MINIDOX'],
# 'val_names': ['DEF', 'MINI', 'CF', 'MDOX']
},
{
'name': '{}', 'vars': ['oled_mount_type'],
'vals': ['CLIP', 'NONE'],
'val_names': ['OLED', 'NOLED']
},
{
'name': '{}CTRL', 'vars': ['controller_mount_type'],
'vals': ['EXTERNAL', 'RJ9_USB_WALL'],
'val_names': ['EXT', 'DEF'],
},
]
def create_config(config_options):
configurations = [{
'config_name': 'DM',
'save_dir': 'DM',
}]
config_options = copy.deepcopy(config_options)
for opt in config_options:
new_configurations = []
for config in configurations:
# config['vals'] = []
for i_vals, vals in enumerate(opt['vals']):
temp_opt = copy.deepcopy(opt)
new_config = copy.deepcopy(config)
if len(temp_opt['vars']) == 1:
vals=[vals]
if 'val_names' in temp_opt:
temp_opt['val_names'][i_vals] = [temp_opt['val_names'][i_vals]]
for i_val, val in enumerate(vals):
new_config[opt['vars'][i_val]] = val
if 'val_names' in temp_opt:
n_input = temp_opt['val_names'][i_vals]
else:
n_input = vals
new_config['config_name'] += "_" + temp_opt['name'].format(*n_input)
new_config['save_dir'] = new_config['config_name']
new_configurations.append(new_config)
configurations = new_configurations
return configurations
def build_release(base, configurations, engines=('solid', 'cadquery')):
init = True
for config in configurations:
shape_config = copy.deepcopy(base)
for item in config:
shape_config[item] = config[item]
for engine in engines:
shape_config['ENGINE'] = engine
with open('run_config.json', mode='w') as fid:
json.dump(shape_config, fid, indent=4)
if init:
import dactyl_manuform as dactyl_manuform
dactyl_manuform.run()
init = False
else:
importlib.reload(dactyl_manuform)
dactyl_manuform.run()
if __name__ == '__main__':
configurations = create_config(config_options)
ENGINES = ['solid', 'cadquery']
# ENGINES = ['solid']
build_release(base, configurations, ENGINES)
|