Skip to content

Commit 6f3ef04

Browse files
author
MichalO
committed
added functions GetResultTableParameters() and ConvertResultsToListOfDct()
We can't extract lines with description like Extremes, Total, and Average. Those are language dependent now.
1 parent 22f6501 commit 6f3ef04

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

RFEM/Results/resultTables.py

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,76 @@
22
from RFEM.initModel import Model
33
from RFEM.enums import CaseObjectType
44

5+
# We can't extract lines with description: Extremes, Total, and Average. Those are language dependent now.
6+
7+
def GetResultTableParameters(results):
8+
'''
9+
Returns dict with 3 atributes: base, row and error.
10+
'''
11+
params = {'base':[], 'row':[], 'error': None}
12+
if results[0][0]:
13+
for i in results[0]:
14+
params['base'] = list(set(params['base'] + i.__keylist__))
15+
if 'row' in i.__keylist__:
16+
params['row'] = list(set(params['row'] + i.row.__keylist__))
17+
else:
18+
params['errors'] = "Result table doesn't have attribute 'row'."
19+
20+
return params
21+
22+
def ConvertResultsToListOfDct(results, includeBase = True):
23+
'''
24+
Args:
25+
results (ResultTables class):
26+
includeBase (bool): Include base information of every line. Typicaly object number and description. Default False.
27+
Returns:
28+
List of dictionaries. Each dictionary corresponds to one line in result table.
29+
'''
30+
params = GetResultTableParameters(results)
31+
lstOfDct = []
32+
33+
for r in results[0]:
34+
dct = {}
35+
if includeBase and params['base']:
36+
for i in params['base']:
37+
if i == 'row':
38+
for y in params['row']:
39+
# Sometimes the parameters are not in table or
40+
# they are defined by type+value structure called 'variant',
41+
# hence using try-except notation
42+
try:
43+
dct[y] = r.row[y].value
44+
except:
45+
try:
46+
dct[y] = r.row[y]
47+
except:
48+
pass
49+
else:
50+
try:
51+
dct[i] = r[i]
52+
except:
53+
pass
54+
lstOfDct.append(dct)
55+
# include only row
56+
else:
57+
if params['row']:
58+
for i in params['row']:
59+
try:
60+
dct[i] = r.row[i].value
61+
except:
62+
try:
63+
dct[i] = r.row[i]
64+
except:
65+
pass
66+
lstOfDct.append(dct)
67+
68+
if params['error']:
69+
return lstOfDct.append({'error': params['error']})
70+
71+
return lstOfDct
72+
573
class ResultTables():
74+
675
@staticmethod
776
def BuildingStoriesForcesInSpandrels(
877
loading_type: enum = CaseObjectType.E_OBJECT_TYPE_LOAD_CASE,
@@ -307,7 +376,7 @@ def LinesSupportForces(
307376
model (class, optional): Model instance
308377
'''
309378

310-
return model.clientModel.service.get_results_for_lines_support_forces(loading_type.name, loading_no, object_no)
379+
return ConvertResultsToListOfDct(model.clientModel.service.get_results_for_lines_support_forces(loading_type.name, loading_no, object_no))
311380

312381
@staticmethod
313382
def MembersByEigenvector(

0 commit comments

Comments
 (0)