-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.py
338 lines (318 loc) · 23.2 KB
/
ui.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
#!/usr/bin/env python
import PySimpleGUI as sg
import shutil
import time
import os
import traceback
from connectors.solidworks import newDoc, closeDoc, createCylinder, setPreferences, openDoc, saveImage, runStudy
from connectors.excel import updateValues
from connectors.data import saveSettings, loadSettings, exportResults
from connectors.formulas import calculateTank
environmental_vars = {
'snow': {"name": "Snow Pressure",
"fields": ['Ce', 'Ct', 'Is', 'Pg'],
},
'wind': {"name": "Wind Pressure",
"fields": ['q', 'qi', 'qh', 'G', 'Cp', 'GCpi'],
},
'seismic': {"name": "Seismic:",
"fields": ['Ss', 'S1', 'Fv', 'Fa', 'Tl'],
},
}
def app():
sg.theme('LightGrey1')
sg.set_options(element_padding=(0, 0))
# ------ Menu Definition ------ #
menu_def = [
['&File', ['&Open', '&Save', 'E&xit']],
['SolidWorks', ['Start SolidWorks', 'New Document',
'Close Document', 'Set Preferences']],
['&Help', ['&About...']]
]
right_click_menu = ['Unused', [
'Right', '!&Click', '&Menu', 'E&xit', 'Properties']]
# ------ GUI Defintion ------ #
# Main tank tab
features = [
[sg.Text('Tank Internal Diameter (in):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 144, 1)], initial_value=36, key='diameter', size=(5, 20))],
[sg.Text('Tank Height (in):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 10000, 1)], initial_value=76, key='height', size=(5, 20))],
[sg.Text('Internal Pressure (psi):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 15, 1)], initial_value=0, key='internal_pressure', size=(5, 20))],
[sg.Text('External Pressure (psi):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 15, 1)], initial_value=0, key='external_pressure', size=(5, 20))],
[sg.Text('Tank Type:', pad=(10, 3)),
sg.Combo(values=['FRP', 'Dual Laminate'], default_value='FRP', key='tank_type', size=(20, 20), enable_events=True)],
[sg.Text('Bottom Head Type:', pad=(10, 3)),
sg.Combo(values=['Torispherical', 'Conical', 'Hemispherical', 'Flat', 'Balsa Wood Core'], default_value='Flat', key='bottom_head', size=(20, 20))],
[sg.Text('Ignore Corrosion Barrier:', pad=(10, 3)),
sg.Checkbox('', key='corrosion_barrier', default=True, enable_events=True)],
[sg.Text('Corrosion Barrier Thickness (in):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 15, 1)], initial_value=0, key='corrosion_barrier_thickness', size=(5, 20), disabled=True)],
[sg.Text('Corrosion Liner Thickness (in):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 15, 1)], initial_value=0, key='corrosion_liner_thickness', size=(5, 20), disabled=True)],
]
# Environment tab
environment = [
[sg.Text('Tensile Operating Force (lbf):', pad=(10, 3)),
sg.Checkbox('', key='tensile_force', enable_events=True),
sg.Spin(values=[i for i in range(0, 15, 1)], initial_value=0, key='tensile_force_value', size=(5, 40), disabled=True)],
[sg.Text('Operating Moment (in-lb):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 15, 1)], initial_value=0, key='operating_moment', size=(5, 40), disabled=True)],
[sg.Text('Is tank outside?', pad=(10, 3)),
sg.Checkbox('', key='outdoor', default=False, enable_events=True)],
[sg.Text('Compressive Operating Force (in-lb):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 15, 1)], initial_value=0, key='compressive_force', size=(5, 20), disabled=True)],
]
# dynamic environment
for key, value in environmental_vars.items():
spinners = []
# add fields and spinners
for field in value['fields']:
spinners.append(sg.Text(text=field, pad=(10, 3)))
spinners.append(sg.Spin(values=[i for i in range(
0, 15, 1)], initial_value=0, key=f'{key}_{field}', size=(5, 20), disabled=True))
# add to correct row in environment tab
environment.append([sg.Text(value['name'], pad=(10, 3)),
sg.Checkbox('', key=key, default=False,
enable_events=True),
*spinners])
# Tank contents tab
contents = [
[sg.Text('Storage Type:', pad=(10, 3)),
sg.Combo(values=['Liquid', 'Gas'], default_value='Gas',
key='storage_type', size=(10, 20), enable_events=True),
sg.Text('Specific Gravity:', pad=(10, 3),
key='specific_gravity_text'),
sg.Spin(values=[i for i in range(0, 15, 1)], initial_value=0, key='specific_gravity', size=(5, 20), disabled=True)],
[sg.Text('Height of Liquid (in):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 15, 1)], initial_value=0, key='liquid_height', size=(5, 20))],
]
# Top Head
top_head = [
[sg.Text('Type:', pad=(10, 3)),
sg.Combo(values=['Torispherical', 'Ellipsoidal', 'Flat'], default_value='Flat', key='top_head', size=(20, 20))],
[sg.Text('Live load (lbf):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='live_load', size=(5, 20))],
[sg.Text('Dead load (lbf):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='dead_load', size=(5, 20))],
]
# Nozzle
nozzle = [
[sg.Text('Number of Nozzles:', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='nozzles', size=(5, 20))],
[sg.Text('Length of Nozzle (in):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='nozzle_length', size=(5, 20))],
[sg.Text('Thickness of Nozzle (in):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='nozzle_thickness', size=(5, 20))],
[sg.Text('Diameter of Nozzle (in):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='nozzle_diameter', size=(5, 20))],
]
# Shell
shell = [
[sg.Text('Type:', pad=(10, 3)),
sg.Combo(values=['Hand Lay-Up', 'Filament Wound'], default_value='Hand Lay-Up', key='shell', size=(20, 20))],
[sg.Text('Thickness per Ply (in):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='thickness_per_ply', size=(5, 20))],
[sg.Text('Hoop Tensile Modulus (psi):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='hoop_tensile_modulus', size=(5, 20))],
[sg.Text('Hoop Tensile Strength (psi):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='hoop_tensile_strength', size=(5, 20))],
[sg.Text('Axial Tensile Modulus (psi):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='axial_tensile_modulus', size=(5, 20))],
[sg.Text('Axial Tensile Strength (psi):', pad=(10, 3)),
sg.Spin(values=[i for i in range(0, 100, 1)], initial_value=0, key='axial_tensile_strength', size=(5, 20))],
]
actions = sg.Column([[sg.Frame('Actions:',
[[sg.Column([[sg.Button('Create Report'), sg.Button('Create Model'), sg.Button('Run Simulation'), sg.Text('Tank Name:', pad=(10, 3)), sg.InputText(key='tank_name', size=(20, 20))]],
pad=(0, 0))]])]], pad=(0, 0))
layout = [
[sg.Menu(menu_def, font='_ 12', key='-MENUBAR-')],
[[sg.TabGroup([[sg.Tab('Features', features), sg.Tab('Environment', environment), sg.Tab('Contents', contents),
sg.Tab('Top Head', top_head), sg.Tab('Shell', shell),
sg.Tab('Nozzle', nozzle)]],
key='-TAB GROUP-', expand_x=True, expand_y=True),]], [actions]]
window = sg.Window("Auto FRP Tank", layout, resizable=True,
right_click_menu=right_click_menu, icon=b'iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAnWSURBVHhe7Z0HjBVdFccvvfcivTdBEAMkgJQQjICU0EtoEgmIICBKaFEIhGYUoglB+scXBEIEKUqRIgQwSAQRCBCKKL036e36/595877Z4e3bXfbte/tmzy/5Z+/cqe+eueeee+fOrFEURVEURVEURVEURVEURVEURVEURVEURVEURVEURVEURVEURVEURVEURVGCRK7Q32SB11scKgYVgnJD5D10C3olS0qY7GbgSlBDqA5UCyoCjYUaQX+FykCuUf10hXZC/4G431PoPnQHug39N6TL0HnoBaTEgc7QX6BHkPXpKkS+BfnX+fU9iLAmR1rv1QeIhv4dVBFSsoju0EcokhGorDKwVzR0KSiQpObu4sXPoUQ3E7WhHznJ4JHown0D5XeSEWF7WhNi29uDGVHYC92AWIMz6nb/CPV2kkosieQyvXJddEbIqIumdkCBJNE1mIUbDbcGM6JezIwozIZOQJ9Tg/8EMR5QYoy/JvkVjyCLCmwNTnSQpWQxauCAowZOCaP1b0IcOeNoWnkoWpSf7UmWIOvr0B+YEYUfQoehzARZ34fWMMPHc4hDnhS7YldCOgn9C1JSwR/s+BXvbhINHGl9NP0ZKgplS5LFRbMA26ah0lAiYPT+Syep+IlUI7yKdzfpc2owxSdX2RINsmIDn1Fny2BMDRxw1MABRw0ccJKlH8w27tvMiMI/IE7RyYp+cHooAL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RN5PqZFx49eiT6XEvJ+vXrLQakxWC0GKRS33Xr1skGrnnz5qIza9YsKcO2cz+BgSn6/fr1k3bAW4geQZ+dQBB8G/8B5PSFEQC73j9jBP/KJc2BAwdk1kyZMsVgoyOz5NatW2bo0KEyo/bu3Svubs6cOaZr165ShrP19u3bBhsimSUsl5GRYbC5Ma1btzZLly41VapUEd234axp0aKFzFwfumzqp6SkSMg60V2fPXvW9O/fX45eucFZySUBxjF169aVtZv1ZDtgGFkCuBbzGMY68/6dOnUy2GAaDDpTvXp1cf/0LvQgvBc9Qtu23okS96+D+xTHoNgnGREi0i86+O3yAVQ24gOnKAADcxPyKQYIX7pEhEi/6OCP43n+t7LQX+WiobiDwfIn6DVAXNb0MPwNut8jXAB97y1D3jmDsstR7hPEx3hZAbJwbQqu1UU83FclX0DvFfQWIZ79rdtN5Of2NUp2HkH/tosrSngiOoPzClx5NYzSTzHai8q3zA/R3u8g3jvUKBJ1A8O4P0WwF42Vb52KChjMPFB3xfqa7+/MPoQCOQfnAnfZRcq4BG3mPuIvXip6xMLADV1YFGnmwqgRCwMrUUQNnOCogROcWBi4QH41iRO8n6KiSNQNjN3kGRctikS97bE4B3+EYDcM/c53W4kMzsEn0WZ+EMi/dxk1YvImC40tBuG/JcrX149xDP/fFBcgUXfRiqIoiqIoiqIoiqIoiqIoiqIoiqIoiqIoiqIoiqIoiqIoiqIoiqIoiqIoSgJhzP8BCNQWVFpAEgoAAAAASUVORK5CYII=')
# TODO: add error handling for specific cases
# have 1 large try except for all events and display error message according to the error type
while True:
event, values = window.read()
if event in (sg.WIN_CLOSED, 'Exit'):
break
print(event, values)
# Functional Events
if event == 'About...':
window.disappear()
sg.popup('About this program', 'Version 1.0',
'PySimpleGUI Version', sg.get_versions())
window.reappear()
elif event == 'Open':
try:
filename = sg.popup_get_file(
'file to open', no_window=True)
settings = loadSettings(filename)
# update keys with settings
for key in settings:
window[key].update(settings[key])
except Exception as e:
print(e)
sg.popup('Open Failed')
elif event == 'Save':
try:
filename = sg.popup_get_file(
'file to save', no_window=True, save_as=True)
# save settings remove -MENUBAR- and -TAB GROUP-
values.pop('-MENUBAR-')
# if values['thickness'] exists, remove it from values
if 'thickness' in values:
values.pop('thickness')
values.pop('-TAB GROUP-')
saveSettings(filename, values)
except Exception as e:
print(e)
sg.popup('Save Failed')
elif event == 'Start SolidWorks':
try:
print('Starting SolidWorks')
os.popen(
'"C:/Program Files/SOLIDWORKS Corp/SOLIDWORKS/SLDWORKS.exe"')
except Exception as e:
print(e)
sg.popup('SolidWorks Failed to Start')
elif event == 'New Document':
try:
newDoc()
except Exception as e:
print(e)
sg.popup('New Document Failed')
elif event == 'Close Document':
closeDoc()
elif event == 'Create Report':
try:
if values['tank_name'] == '':
filename = sg.popup_get_file(
'file to save', no_window=True, save_as=True, file_types=(('HTML Files', '*.html'),))
values['tank_name'] = filename.split('/')[-1].split('.')[0]
window['tank_name'].update(values['tank_name'])
else:
filename = f'{values["tank_name"]}.html'
# calculate tank
exportResults(filename, calculateTank(values))
except Exception as e:
print(traceback.format_exc())
sg.popup('Error', e)
elif event == 'Create Model':
try:
if values['tank_name'] == '':
filename = sg.popup_get_file(
'file to save', no_window=True, save_as=True, file_types=(('HTML Files', '*.html'),))
values['tank_name'] = filename.split('/')[-1].split('.')[0]
window['tank_name'].update(values['tank_name'])
else:
filename = f'{values["tank_name"]}.html'
# calculate tank
exportResults(filename, calculateTank(values))
# close any open documents
closeDoc()
time.sleep(2)
# calculate tank
tank = calculateTank(values)
# createCylinder(float(window.find_element('diameter').get()), float(window.find_element('height').get()))
# update preferences to automatically use excel values
previousPreference = setPreferences(2)
# update excel values
updateValues(25.4*float(tank['height']), 25.4*(float(
tank['diameter']) + float(tank['thickness'])), 25.4*float(tank['diameter']))
file = f'{values["top_head"]}_Head_{"Wood" if values["bottom_head"] == "Balsa Wood Core" else values["bottom_head"]}_Bottom'
# Move file to exec directory
shutil.copy(
f'C:/autofrp/models/{file}.SLDPRT', f'C:/autofrp/{file}.SLDPRT')
shutil.copy(
f'C:/autofrp/models/{file}-Static 1.CWR', f'C:/autofrp/{file}-Static 1.CWR')
# open part
openDoc(f'C:/autofrp/{file}.SLDPRT')
# revert to previous preference
setPreferences(previousPreference)
except Exception as e:
print(e)
sg.popup('Error', e)
elif event == 'Run Simulation':
try:
# calculate tank
tank = calculateTank(values)
runStudy(float(tank['thickness']), float(tank['thickness_per_ply']), -1*float(tank['internal_pressure']),
float(tank['external_pressure']))
except Exception as e:
print(e)
sg.popup('Error', e)
elif event == 'Clear':
try:
closeDoc()
except:
sg.popup('Clear Failed')
elif event == 'Set Preferences':
try:
setPreferences(2)
except:
sg.popup('Set Preferences Failed')
# UI events
elif event == 'storage_type':
if values['storage_type'] == 'Liquid':
window.find_element('specific_gravity').update(disabled=False)
else:
window.find_element('specific_gravity').update(disabled=True)
elif event == 'snow':
for value in environmental_vars['snow']['fields']:
window.find_element(f'snow_{value}').update(
disabled=not values['snow'])
elif event == 'wind':
for value in environmental_vars['wind']['fields']:
window.find_element(f'wind_{value}').update(
disabled=not values['wind'])
elif event == 'seismic':
for value in environmental_vars['seismic']['fields']:
window.find_element(f'seismic_{value}').update(
disabled=not values['seismic'])
elif event == 'tensile_force':
window.find_element('tensile_force_value').update(
disabled=not values['tensile_force'])
if not values['outdoor']:
window.find_element(
'operating_moment').update(disabled=not values['tensile_force'])
elif event == 'corrosion_barrier':
window.find_element('corrosion_barrier_thickness').update(
disabled=values['corrosion_barrier'])
window.find_element('corrosion_liner_thickness').update(
disabled=values['corrosion_barrier'])
if values['tank_type'] == 'FRP':
window.find_element('corrosion_liner_thickness').update(
disabled=True)
window.find_element('corrosion_liner_thickness').update(
value=0)
elif event == 'tank_type':
if (not values['corrosion_barrier']):
if values['tank_type'] == 'Dual Laminate':
window.find_element('corrosion_liner_thickness').update(
disabled=False)
else:
window.find_element('corrosion_liner_thickness').update(
disabled=True)
window.find_element('corrosion_liner_thickness').update(
value=0)
elif event == 'outdoor':
elements = ['compressive_force', 'operating_moment']
if values['tensile_force']:
elements.remove('operating_moment')
for element in elements:
window.find_element(element).update(
disabled=not values['outdoor'])
# update all environmental fields as well
for env in environmental_vars:
window.find_element(env).update(value=values['outdoor'])
for value in environmental_vars[env]['fields']:
window.find_element(f'{env}_{value}').update(
disabled=not values['outdoor'])
window.close()
app()