midas-civil 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of midas-civil might be problematic. Click here for more details.
- midas_civil/__init__.py +24 -0
- midas_civil/_boundary.py +504 -0
- midas_civil/_construction.py +415 -0
- midas_civil/_element.py +275 -0
- midas_civil/_group.py +312 -0
- midas_civil/_load.py +384 -0
- midas_civil/_mapi.py +66 -0
- midas_civil/_material.py +393 -0
- midas_civil/_model.py +352 -0
- midas_civil/_node.py +146 -0
- midas_civil/_result.py +488 -0
- midas_civil/_result_extract.py +103 -0
- midas_civil/_section.py +739 -0
- midas_civil/_thickness.py +139 -0
- midas_civil/_utils.py +83 -0
- midas_civil-0.0.1.dist-info/METADATA +54 -0
- midas_civil-0.0.1.dist-info/RECORD +20 -0
- midas_civil-0.0.1.dist-info/WHEEL +5 -0
- midas_civil-0.0.1.dist-info/licenses/LICENSE +21 -0
- midas_civil-0.0.1.dist-info/top_level.txt +1 -0
midas_civil/__init__.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from ._mapi import *
|
|
2
|
+
from ._model import *
|
|
3
|
+
from ._boundary import *
|
|
4
|
+
# from .section import *
|
|
5
|
+
from ._utils import *
|
|
6
|
+
from ._node import *
|
|
7
|
+
from ._element import *
|
|
8
|
+
from ._load import *
|
|
9
|
+
from ._group import *
|
|
10
|
+
from ._result_extract import *
|
|
11
|
+
|
|
12
|
+
#--- TESTING IMPORTS ---
|
|
13
|
+
from ._material import *
|
|
14
|
+
from ._section import *
|
|
15
|
+
# from .element_new import *
|
|
16
|
+
|
|
17
|
+
from ._result_extract import *
|
|
18
|
+
from ._construction import *
|
|
19
|
+
from ._thickness import *
|
|
20
|
+
|
|
21
|
+
print('')
|
|
22
|
+
print('*'*20,' MIDAS CIVIL-NX PYTHON LIBRARY 🐍 ','*'*20)
|
|
23
|
+
print('')
|
|
24
|
+
|
midas_civil/_boundary.py
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
from ._mapi import *
|
|
2
|
+
from ._model import *
|
|
3
|
+
from ._node import *
|
|
4
|
+
from ._group import *
|
|
5
|
+
|
|
6
|
+
def convList(item):
|
|
7
|
+
if type(item)!=list:
|
|
8
|
+
return [item]
|
|
9
|
+
else:
|
|
10
|
+
return item
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Boundary:
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def create(cls):
|
|
17
|
+
"""Creates Boundary elements in MIDAS Civil NX"""
|
|
18
|
+
if cls.Support.sups!=[]: cls.Support.create()
|
|
19
|
+
if cls.ElasticLink.links!=[]: cls.ElasticLink.create()
|
|
20
|
+
if cls.RigidLink.links!=[]: cls.RigidLink.create()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def delete(cls):
|
|
25
|
+
"""Delets Boundary elements from MIDAS Civil NX and Python"""
|
|
26
|
+
cls.Support.delete()
|
|
27
|
+
cls.ElasticLink.delete()
|
|
28
|
+
cls.RigidLink.delete()
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def sync(cls):
|
|
32
|
+
"""Sync Boundary elements from MIDAS Civil NX to Python"""
|
|
33
|
+
cls.Support.sync()
|
|
34
|
+
cls.ElasticLink.sync()
|
|
35
|
+
cls.RigidLink.sync()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class Support:
|
|
41
|
+
"""Create Support Object in Python \n\nNode ID, Constraint, Boundary Group. Sample: Support(3, "1110000") or Support(3, "pin"). \nValid inputs for DOF are 1s and 0s or "pin", "fix", "free" (no capital letters).
|
|
42
|
+
\nIf more than 7 characters are entered, then only first 7 characters will be considered to define constraint."""
|
|
43
|
+
sups = []
|
|
44
|
+
def __init__(self, node, constraint, group = ""):
|
|
45
|
+
if not isinstance(constraint, str): constraint = str(constraint)
|
|
46
|
+
if constraint == "pin": constraint = "111"
|
|
47
|
+
if constraint == "fix": constraint = "1111111"
|
|
48
|
+
if constraint == "roller": constraint = "001"
|
|
49
|
+
if len(constraint) < 7: constraint = constraint + '0' * (7-len(constraint))
|
|
50
|
+
if len(constraint) > 7: constraint = constraint[:7]
|
|
51
|
+
string = ''.join(['1' if char != '0' else '0' for char in constraint])
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
self.NODE = node
|
|
56
|
+
self.CONST = string
|
|
57
|
+
self.GROUP = group
|
|
58
|
+
self.ID = len(Boundary.Support.sups) + 1
|
|
59
|
+
Boundary.Support.sups.append(self)
|
|
60
|
+
|
|
61
|
+
@classmethod
|
|
62
|
+
def json(cls):
|
|
63
|
+
"""Creates JSON from Supports objects defined in Python"""
|
|
64
|
+
json = {"Assign":{}}
|
|
65
|
+
ng = []
|
|
66
|
+
for i in Boundary.Support.sups:
|
|
67
|
+
if i.NODE in Node.ids:
|
|
68
|
+
json["Assign"][i.NODE] = {"ITEMS":
|
|
69
|
+
[{"ID": i.ID,
|
|
70
|
+
"CONSTRAINT":i.CONST,
|
|
71
|
+
"GROUP_NAME": i.GROUP}]
|
|
72
|
+
}
|
|
73
|
+
if i.NODE not in Node.ids: ng.append(i.NODE)
|
|
74
|
+
if len(ng) > 0: print("These nodes are not defined: ", ng)
|
|
75
|
+
return json
|
|
76
|
+
|
|
77
|
+
@staticmethod
|
|
78
|
+
def create():
|
|
79
|
+
"""Creates Supports in MIDAS Civil NX"""
|
|
80
|
+
MidasAPI("PUT","/db/cons",Boundary.Support.json())
|
|
81
|
+
|
|
82
|
+
@staticmethod
|
|
83
|
+
def get():
|
|
84
|
+
"""Get the JSON of Supports from MIDAS Civil NX"""
|
|
85
|
+
return MidasAPI("GET","/db/cons")
|
|
86
|
+
|
|
87
|
+
@staticmethod
|
|
88
|
+
def sync():
|
|
89
|
+
"""Sync Supports from MIDAS Civil NX to Python"""
|
|
90
|
+
a = Boundary.Support.get()
|
|
91
|
+
if a != {'message': ''}:
|
|
92
|
+
if list(a['CONS'].keys()) != []:
|
|
93
|
+
Boundary.Support.sups = []
|
|
94
|
+
for j in a['CONS'].keys():
|
|
95
|
+
Boundary.Support(int(j),a['CONS'][j]['ITEMS'][0]['CONSTRAINT'])
|
|
96
|
+
|
|
97
|
+
@staticmethod
|
|
98
|
+
def delete():
|
|
99
|
+
"""Delete Supports from MIDAS Civil NX and Python"""
|
|
100
|
+
Boundary.Support.sups=[]
|
|
101
|
+
return MidasAPI("DELETE","/db/cons")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
#---------------------------------------------------------------------------------------------------------------
|
|
107
|
+
#Class to define Elastic Links:
|
|
108
|
+
class ElasticLink:
|
|
109
|
+
|
|
110
|
+
# list to store all link instances
|
|
111
|
+
links = []
|
|
112
|
+
|
|
113
|
+
def __init__(self,
|
|
114
|
+
i_node: int,
|
|
115
|
+
j_node: int,
|
|
116
|
+
group: str = "",
|
|
117
|
+
id: int = None,
|
|
118
|
+
link_type: str = "GEN",
|
|
119
|
+
sdx: float = 0,
|
|
120
|
+
sdy: float = 0,
|
|
121
|
+
sdz: float = 0,
|
|
122
|
+
srx: float = 0,
|
|
123
|
+
sry: float = 0,
|
|
124
|
+
srz: float = 0,
|
|
125
|
+
shear: bool = False,
|
|
126
|
+
dr_y: float = 0.5,
|
|
127
|
+
dr_z: float = 0.5,
|
|
128
|
+
beta_angle: float = 0,
|
|
129
|
+
dir: str = "Dy",
|
|
130
|
+
func_id: int = 1,
|
|
131
|
+
distance_ratio: float = 0):
|
|
132
|
+
"""
|
|
133
|
+
Elastic link.
|
|
134
|
+
Parameters:
|
|
135
|
+
i_node: The first node ID
|
|
136
|
+
j_node: The second node ID
|
|
137
|
+
group: The group name (default "")
|
|
138
|
+
id: The link ID (optional)
|
|
139
|
+
link_type: Type of link (GEN, RIGID, TENS, COMP, MULTI LINEAR, SADDLE, RAIL INTERACT) (default "GEN")
|
|
140
|
+
sdx: Spring stiffness in X direction (default 0)
|
|
141
|
+
sdy: Spring stiffness in Y direction (default 0)
|
|
142
|
+
sdz: Spring stiffness in Z direction (default 0)
|
|
143
|
+
srx: Rotational stiffness around X axis (default 0)
|
|
144
|
+
sry: Rotational stiffness around Y axis (default 0)
|
|
145
|
+
srz: Rotational stiffness around Z axis (default 0)
|
|
146
|
+
shear: Consider shear effects (default False)
|
|
147
|
+
dr_y: Distance ratio for Y direction (default 0.5)
|
|
148
|
+
dr_z: Distance ratio for Z direction (default 0.5)
|
|
149
|
+
beta_angle: Rotation angle in degrees (default 0)
|
|
150
|
+
dir: Direction for MULTI LINEAR or RAIL INTERACT links (default "Dy")
|
|
151
|
+
func_id: Function ID for MULTI LINEAR or RAIL INTERACT links (default 1)
|
|
152
|
+
distance_ratio: Distance ratio for MULTI LINEAR or RAIL INTERACT links (default 0)
|
|
153
|
+
|
|
154
|
+
Examples:
|
|
155
|
+
```python
|
|
156
|
+
# General link with all stiffness parameters
|
|
157
|
+
ElasticLink(1, 2, "Group1", 1, "GEN", 1000, 1000, 1000, 100, 100, 100)
|
|
158
|
+
# Rigid link
|
|
159
|
+
ElasticLink(3, 4, "Group2", 2, "RIGID")
|
|
160
|
+
# Tension-only link
|
|
161
|
+
ElasticLink(5, 6, "Group3", 3, "TENS", 500)
|
|
162
|
+
# Compression-only link
|
|
163
|
+
ElasticLink(7, 8, "Group4", 4, "COMP", 500)
|
|
164
|
+
# Rail Track Type link
|
|
165
|
+
ElasticLink(9, 10, "Group5", 5, "RAIL INTERACT", dir="Dy", func_id=1)
|
|
166
|
+
# Multi Linear Link
|
|
167
|
+
ElasticLink(11, 12, "Group6", 6, "MULTI LINEAR", dir="Dy", func_id=1)
|
|
168
|
+
# Saddle type link
|
|
169
|
+
ElasticLink(13, 14, "Group7", 7, "SADDLE")
|
|
170
|
+
```
|
|
171
|
+
"""
|
|
172
|
+
# Check if group exists, create if not
|
|
173
|
+
if group != "":
|
|
174
|
+
chk = 0
|
|
175
|
+
a = [v['NAME'] for v in Group.Boundary.json()["Assign"].values()]
|
|
176
|
+
if group in a:
|
|
177
|
+
chk = 1
|
|
178
|
+
if chk == 0:
|
|
179
|
+
Group.Boundary(group)
|
|
180
|
+
|
|
181
|
+
# Validate link type
|
|
182
|
+
valid_types = ["GEN", "RIGID", "TENS", "COMP", "MULTI LINEAR", "SADDLE", "RAIL INTERACT"]
|
|
183
|
+
if link_type not in valid_types:
|
|
184
|
+
link_type = "GEN"
|
|
185
|
+
|
|
186
|
+
# Validate direction for MULTI LINEAR
|
|
187
|
+
if link_type == "MULTI LINEAR":
|
|
188
|
+
valid_directions = ["Dx", "Dy", "Dz", "Rx", "Ry", "Rz"]
|
|
189
|
+
if dir not in valid_directions:
|
|
190
|
+
dir = "Dy"
|
|
191
|
+
|
|
192
|
+
# Validate direction for RAIL INTERACT
|
|
193
|
+
if link_type == "RAIL INTERACT":
|
|
194
|
+
valid_directions = ["Dy", "Dz"]
|
|
195
|
+
if dir not in valid_directions:
|
|
196
|
+
dir = "Dy"
|
|
197
|
+
|
|
198
|
+
self.I_NODE = i_node
|
|
199
|
+
self.J_NODE = j_node
|
|
200
|
+
self.GROUP_NAME = group
|
|
201
|
+
self.LINK_TYPE = link_type
|
|
202
|
+
self.ANGLE = beta_angle
|
|
203
|
+
|
|
204
|
+
# Parameters for all link types
|
|
205
|
+
self.SDx = sdx
|
|
206
|
+
self.SDy = sdy
|
|
207
|
+
self.SDz = sdz
|
|
208
|
+
self.SRx = srx
|
|
209
|
+
self.SRy = sry
|
|
210
|
+
self.SRz = srz
|
|
211
|
+
self.bSHEAR = shear
|
|
212
|
+
self.DR_Y = dr_y
|
|
213
|
+
self.DR_Z = dr_z
|
|
214
|
+
|
|
215
|
+
# Parameters for MULTI LINEAR and RAIL INTERACT
|
|
216
|
+
self.Direction = dir
|
|
217
|
+
self.Function_ID = func_id
|
|
218
|
+
self.Distance_ratio = distance_ratio
|
|
219
|
+
|
|
220
|
+
# Auto-assign ID if not provided
|
|
221
|
+
if id is None:
|
|
222
|
+
self.ID = len(Boundary.ElasticLink.links) + 1
|
|
223
|
+
else:
|
|
224
|
+
self.ID = id
|
|
225
|
+
|
|
226
|
+
# Add to static list
|
|
227
|
+
Boundary.ElasticLink.links.append(self)
|
|
228
|
+
|
|
229
|
+
@classmethod
|
|
230
|
+
def json(cls):
|
|
231
|
+
"""
|
|
232
|
+
Converts ElasticLink data to JSON format for API submission.
|
|
233
|
+
Example:
|
|
234
|
+
# Get the JSON data for all links
|
|
235
|
+
json_data = ElasticLink.json()
|
|
236
|
+
print(json_data)
|
|
237
|
+
"""
|
|
238
|
+
data = {}
|
|
239
|
+
|
|
240
|
+
for link in cls.links:
|
|
241
|
+
link_data = {
|
|
242
|
+
"NODE": [link.I_NODE, link.J_NODE],
|
|
243
|
+
"LINK": link.LINK_TYPE,
|
|
244
|
+
"ANGLE": link.ANGLE,
|
|
245
|
+
"BNGR_NAME": link.GROUP_NAME
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
# Add type-specific parameters
|
|
249
|
+
if link.LINK_TYPE == "GEN":
|
|
250
|
+
link_data["R_S"] = [False] * 6
|
|
251
|
+
link_data["SDR"] = [
|
|
252
|
+
link.SDx,
|
|
253
|
+
link.SDy,
|
|
254
|
+
link.SDz,
|
|
255
|
+
link.SRx,
|
|
256
|
+
link.SRy,
|
|
257
|
+
link.SRz
|
|
258
|
+
]
|
|
259
|
+
link_data["bSHEAR"] = link.bSHEAR
|
|
260
|
+
if link.bSHEAR:
|
|
261
|
+
link_data["DR"] = [link.DR_Y, link.DR_Z]
|
|
262
|
+
else:
|
|
263
|
+
link_data["DR"] = [0.5, 0.5]
|
|
264
|
+
|
|
265
|
+
elif link.LINK_TYPE in ["TENS", "COMP"]:
|
|
266
|
+
link_data["SDR"] = [link.SDx, 0, 0, 0, 0, 0]
|
|
267
|
+
link_data["bSHEAR"] = link.bSHEAR
|
|
268
|
+
if link.bSHEAR:
|
|
269
|
+
link_data["DR"] = [link.DR_Y, link.DR_Z]
|
|
270
|
+
else:
|
|
271
|
+
link_data["DR"] = [0.5, 0.5]
|
|
272
|
+
|
|
273
|
+
elif link.LINK_TYPE == "MULTI LINEAR":
|
|
274
|
+
direction_mapping = {
|
|
275
|
+
"Dx": 0, "Dy": 1, "Dz": 2, "Rx": 3, "Ry": 4, "Rz": 5
|
|
276
|
+
}
|
|
277
|
+
link_data["DIR"] = direction_mapping.get(link.Direction, 0)
|
|
278
|
+
link_data["MLFC"] = link.Function_ID
|
|
279
|
+
link_data["DRENDI"] = link.Distance_ratio
|
|
280
|
+
|
|
281
|
+
elif link.LINK_TYPE == "RAIL INTERACT":
|
|
282
|
+
direction_mapping = {"Dy": 1, "Dz": 2}
|
|
283
|
+
link_data["DIR"] = direction_mapping.get(link.Direction, 0)
|
|
284
|
+
link_data["RLFC"] = link.Function_ID
|
|
285
|
+
link_data["bSHEAR"] = link.bSHEAR
|
|
286
|
+
if link.bSHEAR:
|
|
287
|
+
link_data["DEENDI"] = link.Distance_ratio
|
|
288
|
+
else:
|
|
289
|
+
link_data["DR"] = [0.5, 0.5]
|
|
290
|
+
|
|
291
|
+
data[link.ID] = link_data
|
|
292
|
+
|
|
293
|
+
return {"Assign": data}
|
|
294
|
+
|
|
295
|
+
@classmethod
|
|
296
|
+
def create(cls):
|
|
297
|
+
"""
|
|
298
|
+
Sends all ElasticLink data to Midas API.
|
|
299
|
+
Example:
|
|
300
|
+
ElasticLink(1, 2, "Group1", 1, "GEN", 1000, 1000, 1000, 100, 100, 100)
|
|
301
|
+
# Send to the API
|
|
302
|
+
ElasticLink.create()
|
|
303
|
+
"""
|
|
304
|
+
MidasAPI("PUT", "/db/elnk", cls.json())
|
|
305
|
+
|
|
306
|
+
@classmethod
|
|
307
|
+
def get(cls):
|
|
308
|
+
"""
|
|
309
|
+
Retrieves ElasticLink data from Midas API.
|
|
310
|
+
Example:
|
|
311
|
+
api_data = ElasticLink.get()
|
|
312
|
+
print(api_data)
|
|
313
|
+
"""
|
|
314
|
+
return MidasAPI("GET", "/db/elnk")
|
|
315
|
+
|
|
316
|
+
@classmethod
|
|
317
|
+
def sync(cls):
|
|
318
|
+
"""
|
|
319
|
+
Updates the ElasticLink class with data from the Midas API.
|
|
320
|
+
Example:
|
|
321
|
+
ElasticLink.sync()
|
|
322
|
+
"""
|
|
323
|
+
cls.links = []
|
|
324
|
+
a = cls.get()
|
|
325
|
+
|
|
326
|
+
if a != {'message': ''}:
|
|
327
|
+
for link_id, link_data in a.get("ELNK", {}).items():
|
|
328
|
+
sdx = sdy = sdz = srx = sry = srz = 0
|
|
329
|
+
shear = False
|
|
330
|
+
dr_y = dr_z = 0.5
|
|
331
|
+
direction = "Dy"
|
|
332
|
+
func_id = 1
|
|
333
|
+
distance_ratio = 0
|
|
334
|
+
|
|
335
|
+
if link_data["LINK"] == "GEN" and "SDR" in link_data:
|
|
336
|
+
sdx, sdy, sdz, srx, sry, srz = link_data["SDR"]
|
|
337
|
+
shear = link_data.get("bSHEAR")
|
|
338
|
+
if shear and "DR" in link_data:
|
|
339
|
+
dr_y, dr_z = link_data["DR"]
|
|
340
|
+
|
|
341
|
+
elif link_data["LINK"] in ["TENS", "COMP"] and "SDR" in link_data:
|
|
342
|
+
sdx = link_data["SDR"][0]
|
|
343
|
+
shear = link_data.get("bSHEAR")
|
|
344
|
+
if shear and "DR" in link_data:
|
|
345
|
+
dr_y, dr_z = link_data["DR"]
|
|
346
|
+
|
|
347
|
+
elif link_data["LINK"] == "MULTI LINEAR":
|
|
348
|
+
dir_mapping = {0: "Dx", 1: "Dy", 2: "Dz", 3: "Rx", 4: "Ry", 5: "Rz"}
|
|
349
|
+
direction = dir_mapping.get(link_data.get("DIR"), "Dy")
|
|
350
|
+
func_id = link_data.get("MLFC")
|
|
351
|
+
distance_ratio = link_data.get("DRENDI")
|
|
352
|
+
|
|
353
|
+
elif link_data["LINK"] == "RAIL INTERACT":
|
|
354
|
+
dir_mapping = {1: "Dy", 2: "Dz"}
|
|
355
|
+
direction = dir_mapping.get(link_data.get("DIR"), "Dy")
|
|
356
|
+
func_id = link_data.get("RLFC")
|
|
357
|
+
shear = link_data.get("bSHEAR")
|
|
358
|
+
if shear and "DEENDI" in link_data:
|
|
359
|
+
distance_ratio = link_data["DEENDI"]
|
|
360
|
+
|
|
361
|
+
Boundary.ElasticLink(
|
|
362
|
+
link_data["NODE"][0],
|
|
363
|
+
link_data["NODE"][1],
|
|
364
|
+
link_data.get("BNGR_NAME"),
|
|
365
|
+
int(link_id),
|
|
366
|
+
link_data["LINK"],
|
|
367
|
+
sdx, sdy, sdz, srx, sry, srz,
|
|
368
|
+
shear, dr_y, dr_z,
|
|
369
|
+
link_data.get("ANGLE"),
|
|
370
|
+
direction, func_id, distance_ratio
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
@classmethod
|
|
374
|
+
def delete(cls):
|
|
375
|
+
"""
|
|
376
|
+
Deletes all elastic links from the database and resets the class.
|
|
377
|
+
Example:sss
|
|
378
|
+
ElasticLink.delete()
|
|
379
|
+
"""
|
|
380
|
+
cls.links = []
|
|
381
|
+
return MidasAPI("DELETE", "/db/elnk")
|
|
382
|
+
#---------------------------------------------------------------------------------------------------------------
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
#Class to define Rigid Links:
|
|
386
|
+
class RigidLink:
|
|
387
|
+
|
|
388
|
+
links = []
|
|
389
|
+
|
|
390
|
+
def __init__(self,
|
|
391
|
+
master_node: int,
|
|
392
|
+
slave_nodes: list,
|
|
393
|
+
group: str = "",
|
|
394
|
+
id: int = None,
|
|
395
|
+
dof: int = 111111,):
|
|
396
|
+
"""
|
|
397
|
+
Rigid link.
|
|
398
|
+
Parameters:
|
|
399
|
+
master_node: The first node ID
|
|
400
|
+
slave_nodes: The second node ID
|
|
401
|
+
group: The group name (default "")
|
|
402
|
+
id: The link ID (optional)
|
|
403
|
+
dof: Fixity of link (default 111111)
|
|
404
|
+
|
|
405
|
+
Examples:
|
|
406
|
+
```python
|
|
407
|
+
# General link with all stiffness parameters
|
|
408
|
+
RigidLink(1, [2,3], "Group1", 1, 111000)
|
|
409
|
+
```
|
|
410
|
+
"""
|
|
411
|
+
|
|
412
|
+
# Check if group exists, create if not
|
|
413
|
+
if group != "":
|
|
414
|
+
chk = 0
|
|
415
|
+
a = [v['NAME'] for v in Group.Boundary.json()["Assign"].values()]
|
|
416
|
+
if group in a:
|
|
417
|
+
chk = 1
|
|
418
|
+
if chk == 0:
|
|
419
|
+
Group.Boundary(group)
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
self.M_NODE = master_node
|
|
423
|
+
self.S_NODE = convList(slave_nodes)
|
|
424
|
+
self.GROUP_NAME = group
|
|
425
|
+
self.DOF = dof
|
|
426
|
+
|
|
427
|
+
# Auto-assign ID if not provided
|
|
428
|
+
if id is None:
|
|
429
|
+
self.ID = len(Boundary.RigidLink.links) + 1
|
|
430
|
+
else:
|
|
431
|
+
self.ID = id
|
|
432
|
+
|
|
433
|
+
# Add to static list
|
|
434
|
+
Boundary.RigidLink.links.append(self)
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
@classmethod
|
|
438
|
+
def json(cls):
|
|
439
|
+
"""
|
|
440
|
+
Converts RigidLink data to JSON format for API submission.
|
|
441
|
+
Example:
|
|
442
|
+
# Get the JSON data for all links
|
|
443
|
+
json_data = RigidLink.json()
|
|
444
|
+
print(json_data)
|
|
445
|
+
"""
|
|
446
|
+
json = {"Assign": {}}
|
|
447
|
+
for link in cls.links:
|
|
448
|
+
if link.M_NODE not in list(json["Assign"].keys()):
|
|
449
|
+
json["Assign"][link.M_NODE] = {"ITEMS": []}
|
|
450
|
+
|
|
451
|
+
json["Assign"][link.M_NODE]["ITEMS"].append({
|
|
452
|
+
"ID": link.ID,
|
|
453
|
+
"GROUP_NAME": link.GROUP_NAME,
|
|
454
|
+
"DOF": link.DOF,
|
|
455
|
+
"S_NODE": convList(link.S_NODE),
|
|
456
|
+
})
|
|
457
|
+
return json
|
|
458
|
+
|
|
459
|
+
@classmethod
|
|
460
|
+
def create(cls):
|
|
461
|
+
"""
|
|
462
|
+
Sends all RigidLink data to Midas API.
|
|
463
|
+
Example:
|
|
464
|
+
RigidLink(1, 2, "Group1", 1, "GEN", 1000, 1000, 1000, 100, 100, 100)
|
|
465
|
+
# Send to the API
|
|
466
|
+
RigidLink.create()
|
|
467
|
+
"""
|
|
468
|
+
MidasAPI("PUT", "/db/RIGD", cls.json())
|
|
469
|
+
|
|
470
|
+
@classmethod
|
|
471
|
+
def get(cls):
|
|
472
|
+
"""
|
|
473
|
+
Retrieves Rigid Link data from Midas API.
|
|
474
|
+
Example:
|
|
475
|
+
api_data = RigidLink.get()
|
|
476
|
+
print(api_data)
|
|
477
|
+
"""
|
|
478
|
+
return MidasAPI("GET", "/db/RIGD")
|
|
479
|
+
|
|
480
|
+
@classmethod
|
|
481
|
+
def sync(cls):
|
|
482
|
+
"""
|
|
483
|
+
Updates the RigidLink class with data from the Midas API.
|
|
484
|
+
Example:
|
|
485
|
+
RigidLink.sync()
|
|
486
|
+
"""
|
|
487
|
+
cls.links = []
|
|
488
|
+
a = cls.get()
|
|
489
|
+
if a != {'message': ''}:
|
|
490
|
+
for i in a['RIGD'].keys():
|
|
491
|
+
for j in range(len(a['RIGD'][i]['ITEMS'])):
|
|
492
|
+
itm = a['RIGD'][i]['ITEMS'][j]
|
|
493
|
+
Boundary.RigidLink(int(i),itm['S_NODE'],itm['GROUP_NAME'],itm['ID'],itm['DOF'])
|
|
494
|
+
|
|
495
|
+
@classmethod
|
|
496
|
+
def delete(cls):
|
|
497
|
+
"""
|
|
498
|
+
Deletes all rigid links from the database and resets the class.
|
|
499
|
+
Example:
|
|
500
|
+
ElasticLink.delete()
|
|
501
|
+
"""
|
|
502
|
+
cls.links = []
|
|
503
|
+
return MidasAPI("DELETE", "/db/RIGD")
|
|
504
|
+
#---------------------------------------------------------------------------------------------------------------
|