forked from dlubal-software/RFEM_Python_Client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobalParameter.py
More file actions
79 lines (60 loc) · 3.41 KB
/
Copy pathglobalParameter.py
File metadata and controls
79 lines (60 loc) · 3.41 KB
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
from RFEM.initModel import Model, clearAtributes
from RFEM.enums import GlobalParameterUnitGroup, GlobalParameterDefinitionType
class GlobalParameter():
def AddParameter(self,
no: int = 1,
name: str = '',
symbol: str = '',
unit_group = GlobalParameterUnitGroup.LENGTH,
definition_type = GlobalParameterDefinitionType.DEFINITION_TYPE_VALUE,
definition_parameter = [],
comment: str = '',
params: dict = {}):
'''
for definition_type = GlobalParameterDefinitionType.DEFINITION_TYPE_FORMULA:
definition_parameter = [formula]
for definition_type = GlobalParameterDefinitionType.DEFINITION_TYPE_OPTIMIZATION:
definition_parameter = [min, max, increment, steps]
for definition_type = GlobalParameterDefinitionType.DEFINITION_TYPE_OPTIMIZATION_ASCENDING:
definition_parameter = [min, max, increment, steps]
for definition_type = GlobalParameterDefinitionType.DEFINITION_TYPE_OPTIMIZATION_DESCENDING:
definition_parameter = [value, min, max, steps]
for definition_type = GlobalParameterDefinitionType.DEFINITION_TYPE_VALUE:
definition_parameter = [value]
'''
# Client model | Global Parameter
clientObject = Model.clientModel.factory.create('ns0:global_parameter')
# Clears object attributes | Sets all attributes to None
clearAtributes(clientObject)
# Global Parameter No.
clientObject.no = no
# Global Parameter Name
clientObject.name = name
# Symbol (HTML)
clientObject.symbol = symbol
# Unit Group
clientObject.unit_group = unit_group.name
# Definition Type
clientObject.definition_type = definition_type.name
if definition_type.name == 'DEFINITION_TYPE_FORMULA':
if len(definition_parameter) != 1:
raise Exception('WARNING: The definition parameter needs to be of length 1. Kindly check list inputs for completeness and correctness.')
clientObject.formula = definition_parameter[0]
elif definition_type.name == 'DEFINITION_TYPE_OPTIMIZATION' or definition_type.name == 'DEFINITION_TYPE_OPTIMIZATION_ASCENDING' or definition_type.name == 'DEFINITION_TYPE_OPTIMIZATION_DESCENDING':
if len(definition_parameter) != 4:
raise Exception('WARNING: The definition parameter needs to be of length 4. Kindly check list inputs for completeness and correctness.')
clientObject.value = definition_parameter[0]
clientObject.min = definition_parameter[1]
clientObject.max = definition_parameter[2]
clientObject.steps = definition_parameter[3]
elif definition_type.name == 'DEFINITION_TYPE_VALUE':
if len(definition_parameter) != 1:
raise Exception('WARNING: The definition parameter needs to be of length 1. Kindly check list inputs for completeness and correctness.')
clientObject.value = definition_parameter[0]
# Comment
clientObject.comment = comment
# Adding optional parameters via dictionary
for key in params:
clientObject[key] = params[key]
# Add Global Parameter to client model
Model.clientModel.service.set_global_parameter(clientObject)