|
2 | 2 | from RFEM.initModel import Model
|
3 | 3 | from RFEM.enums import CaseObjectType
|
4 | 4 |
|
| 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 | + |
5 | 73 | class ResultTables():
|
| 74 | + |
6 | 75 | @staticmethod
|
7 | 76 | def BuildingStoriesForcesInSpandrels(
|
8 | 77 | loading_type: enum = CaseObjectType.E_OBJECT_TYPE_LOAD_CASE,
|
@@ -307,7 +376,7 @@ def LinesSupportForces(
|
307 | 376 | model (class, optional): Model instance
|
308 | 377 | '''
|
309 | 378 |
|
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)) |
311 | 380 |
|
312 | 381 | @staticmethod
|
313 | 382 | def MembersByEigenvector(
|
|
0 commit comments