midas-civil 0.0.8__py3-none-any.whl → 0.1.0__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.

@@ -0,0 +1,353 @@
1
+ from ._mapi import *
2
+ from ._node import *
3
+ from ._group import *
4
+
5
+ def convList(item):
6
+ if type(item) != list:
7
+ return [item]
8
+ else:
9
+ return item
10
+
11
+ class Temperature:
12
+
13
+ @classmethod
14
+ def create(cls):
15
+ """Creates Temperature elements in MIDAS Civil NX"""
16
+ if cls.System.temps: cls.System.create()
17
+ if cls.Element.temps: cls.Element.create()
18
+ if cls.Gradient.temps: cls.Gradient.create()
19
+
20
+ @classmethod
21
+ def delete(cls):
22
+ """Deletes Temperature elements from MIDAS Civil NX and Python"""
23
+ cls.System.delete()
24
+ cls.Element.delete()
25
+ cls.Gradient.delete()
26
+
27
+
28
+ @classmethod
29
+ def sync(cls):
30
+ """Sync Temperature elements from MIDAS Civil NX to Python"""
31
+ cls.System.sync()
32
+ cls.Element.sync()
33
+ cls.Gradient.sync()
34
+
35
+ # --------------------------------------------------------------------------------------------------
36
+ # System Temperature
37
+ # --------------------------------------------------------------------------------------------------
38
+ class System:
39
+ """
40
+ Create System Temperature Object in Python
41
+
42
+ Parameters:
43
+ temperature (float): Temperature value
44
+ lcname (str): Load case name
45
+ group (str): Load group name (default "")
46
+ id (int): System ID (optional)
47
+
48
+ Example:
49
+ Temperature.System(12.5, "Temp(+)", "LoadGroup1", 1)
50
+ """
51
+ temps = []
52
+
53
+ def __init__(self, temperature, lcname, group="", id=None):
54
+ if group:
55
+ chk = 0
56
+ try:
57
+ a = [v['NAME'] for v in Group.Load.json()["Assign"].values()]
58
+ if group in a:
59
+ chk = 1
60
+ except:
61
+ pass
62
+ if chk == 0:
63
+ Group.Load(group)
64
+
65
+ self.TEMPER = temperature
66
+ self.LCNAME = lcname
67
+ self.GROUP_NAME = group
68
+
69
+ if id is None:
70
+ self.ID = len(Temperature.System.temps) + 1
71
+ else:
72
+ self.ID = id
73
+
74
+ Temperature.System.temps.append(self)
75
+
76
+ @classmethod
77
+ def json(cls):
78
+ """Creates JSON from System Temperature objects defined in Python"""
79
+ json_data = {"Assign": {}}
80
+ for temp in cls.temps:
81
+ json_data["Assign"][str(temp.ID)] = {
82
+ "TEMPER": temp.TEMPER,
83
+ "LCNAME": temp.LCNAME,
84
+ "GROUP_NAME": temp.GROUP_NAME
85
+ }
86
+ return json_data
87
+
88
+ @staticmethod
89
+ def create():
90
+ """Creates System Temperatures in MIDAS Civil NX"""
91
+ MidasAPI("PUT", "/db/stmp", Temperature.System.json())
92
+
93
+ @staticmethod
94
+ def get():
95
+ """Get the JSON of System Temperatures from MIDAS Civil NX"""
96
+ return MidasAPI("GET", "/db/stmp")
97
+
98
+ @staticmethod
99
+ def sync():
100
+ """Sync System Temperatures from MIDAS Civil NX to Python"""
101
+ Temperature.System.temps = []
102
+ a = Temperature.System.get()
103
+
104
+ if a and 'STMP' in a:
105
+ temp_data = a.get('STMP', {})
106
+ for temp_id, temp_info in temp_data.items():
107
+ Temperature.System(
108
+ temp_info.get('TEMPER', 0),
109
+ temp_info.get('LCNAME', ''),
110
+ temp_info.get('GROUP_NAME', ''),
111
+ int(temp_id)
112
+ )
113
+
114
+ @staticmethod
115
+ def delete():
116
+ """Delete System Temperatures from MIDAS Civil NX and Python"""
117
+ Temperature.System.temps = []
118
+ return MidasAPI("DELETE", "/db/stmp")
119
+
120
+ # --------------------------------------------------------------------------------------------------
121
+ # Element Temperature
122
+ # --------------------------------------------------------------------------------------------------
123
+ class Element:
124
+ """
125
+ Create Element Temperature Object in Python
126
+
127
+ Parameters:
128
+ element (int): Element ID
129
+ temperature (float): Temperature value
130
+ lcname (str): Load case name
131
+ group (str): Load group name (default "")
132
+ id (int): Temperature ID (optional)
133
+
134
+ Example:
135
+ Temperature.Element(1, 35, "Temp(+)", "", 1)
136
+ """
137
+ temps = []
138
+
139
+ def __init__(self, element, temperature, lcname, group="", id=None):
140
+ if group:
141
+ chk = 0
142
+ try:
143
+ a = [v['NAME'] for v in Group.Load.json()["Assign"].values()]
144
+ if group in a:
145
+ chk = 1
146
+ except:
147
+ pass
148
+ if chk == 0:
149
+ Group.Load(group)
150
+
151
+ self.ELEMENT = element
152
+ self.TEMP = temperature
153
+ self.LCNAME = lcname
154
+ self.GROUP_NAME = group
155
+
156
+ if id is None:
157
+ existing_ids = []
158
+ for temp in Temperature.Element.temps:
159
+ if temp.ELEMENT == element:
160
+ existing_ids.extend([item.get('ID', 0) for item in temp.ITEMS if hasattr(temp, 'ITEMS')])
161
+ self.ID = max(existing_ids, default=0) + 1
162
+ else:
163
+ self.ID = id
164
+
165
+ existing_temp = None
166
+ for temp in Temperature.Element.temps:
167
+ if temp.ELEMENT == element:
168
+ existing_temp = temp
169
+ break
170
+
171
+ item_data = {
172
+ "ID": self.ID, "LCNAME": self.LCNAME,
173
+ "GROUP_NAME": self.GROUP_NAME, "TEMP": self.TEMP
174
+ }
175
+
176
+ if existing_temp:
177
+ if not hasattr(existing_temp, 'ITEMS'):
178
+ existing_temp.ITEMS = []
179
+ existing_temp.ITEMS.append(item_data)
180
+ else:
181
+ self.ITEMS = [item_data]
182
+ Temperature.Element.temps.append(self)
183
+
184
+ @classmethod
185
+ def json(cls):
186
+ """Creates JSON from Element Temperature objects defined in Python"""
187
+ json_data = {"Assign": {}}
188
+ for temp in cls.temps:
189
+ json_data["Assign"][str(temp.ELEMENT)] = {"ITEMS": temp.ITEMS}
190
+ return json_data
191
+
192
+ @staticmethod
193
+ def create():
194
+ """Creates Element Temperatures in MIDAS Civil NX"""
195
+ MidasAPI("PUT", "/db/etmp", Temperature.Element.json())
196
+
197
+ @staticmethod
198
+ def get():
199
+ """Get the JSON of Element Temperatures from MIDAS Civil NX"""
200
+ return MidasAPI("GET", "/db/etmp")
201
+
202
+ @staticmethod
203
+ def sync():
204
+ """Sync Element Temperatures from MIDAS Civil NX to Python"""
205
+ Temperature.Element.temps = []
206
+ a = Temperature.Element.get()
207
+
208
+ if a and 'ETMP' in a:
209
+ temp_data = a.get('ETMP', {})
210
+ for element_id, element_data in temp_data.items():
211
+ element_obj = type('obj', (object,), {
212
+ 'ELEMENT': int(element_id),
213
+ 'ITEMS': element_data.get('ITEMS', [])
214
+ })()
215
+ Temperature.Element.temps.append(element_obj)
216
+
217
+ @staticmethod
218
+ def delete():
219
+ """Delete Element Temperatures from MIDAS Civil NX and Python"""
220
+ Temperature.Element.temps = []
221
+ return MidasAPI("DELETE", "/db/etmp")
222
+
223
+ # --------------------------------------------------------------------------------------------------
224
+ # Temperature Gradient
225
+ # --------------------------------------------------------------------------------------------------
226
+ class Gradient:
227
+ """
228
+ Create Temperature Gradient Object in Python for Beam and Plate elements.
229
+
230
+ Parameters:
231
+ element (int): Element ID to apply the gradient.
232
+ type (str): Element type, either 'Beam' or 'Plate'.
233
+ lcname (str): Load Case Name (must exist in the model).
234
+ tz (float): Temperature difference in the local z-direction (T2z - T1z).
235
+ group (str, optional): Load Group Name. Defaults to "".
236
+ id (int, optional): Gradient ID. Auto-assigned if not provided.
237
+ hz (float, optional): Gradient value for local z-dir. If omitted, section default is used.
238
+ ty (float, optional): Temp. diff. in local y-dir (T2y - T1y). **Required for 'Beam' type.**
239
+ hy (float, optional): Gradient value for local y-dir. If omitted, section default is used.
240
+
241
+ Example for Beam (providing gradient values):
242
+ Temperature.Gradient(element=2, type='Beam', lcname='Temp(-)', tz=10, ty=-10, hz=1.2, hy=0.5)
243
+
244
+ Example for Beam (using section defaults):
245
+ Temperature.Gradient(element=2, type='Beam', lcname='Temp(+)', tz=10, ty=-10)
246
+
247
+ Example for Plate (providing gradient value):
248
+ Temperature.Gradient(element=21, type='Plate', lcname='Temp(-)', tz=10, hz=0.2)
249
+ """
250
+ temps = []
251
+
252
+ def __init__(self, element, type, lcname, tz, group="", id=None, hz=None, ty=0, hy=None):
253
+ if group:
254
+ chk = 0
255
+ try:
256
+ a = [v['NAME'] for v in Group.Load.json()["Assign"].values()]
257
+ if group in a:
258
+ chk = 1
259
+ except:
260
+ pass
261
+ if chk == 0:
262
+ Group.Load(group)
263
+
264
+ self.ELEMENT = element
265
+
266
+ if id is None:
267
+ existing_ids = []
268
+ for temp in Temperature.Gradient.temps:
269
+ if temp.ELEMENT == element:
270
+ existing_ids.extend([item.get('ID', 0) for item in temp.ITEMS if hasattr(temp, 'ITEMS')])
271
+ self.ID = max(existing_ids, default=0) + 1
272
+ else:
273
+ self.ID = id
274
+
275
+ use_hz = (hz is None)
276
+ use_hy = (hy is None)
277
+
278
+ item_data = {
279
+ "ID": self.ID,
280
+ "LCNAME": lcname,
281
+ "GROUP_NAME": group,
282
+ "TZ": tz,
283
+ "USE_HZ": use_hz,
284
+ }
285
+
286
+ if not use_hz:
287
+ item_data["HZ"] = hz
288
+
289
+ if type.lower() == 'beam':
290
+ item_data["TYPE"] = 1
291
+ item_data["TY"] = ty
292
+ item_data["USE_HY"] = use_hy
293
+ if not use_hy:
294
+ item_data["HY"] = hy
295
+ elif type.lower() == 'plate':
296
+ item_data["TYPE"] = 2
297
+ else:
298
+ raise ValueError("Element type for Gradient must be 'Beam' or 'Plate'.")
299
+
300
+ existing_temp = None
301
+ for temp in Temperature.Gradient.temps:
302
+ if temp.ELEMENT == element:
303
+ existing_temp = temp
304
+ break
305
+
306
+ if existing_temp:
307
+ if not hasattr(existing_temp, 'ITEMS'):
308
+ existing_temp.ITEMS = []
309
+ existing_temp.ITEMS.append(item_data)
310
+ else:
311
+ self.ITEMS = [item_data]
312
+ Temperature.Gradient.temps.append(self)
313
+
314
+ @classmethod
315
+ def json(cls):
316
+ """Creates JSON from Temperature Gradient objects defined in Python"""
317
+ json_data = {"Assign": {}}
318
+ for temp in cls.temps:
319
+ json_data["Assign"][str(temp.ELEMENT)] = {"ITEMS": temp.ITEMS}
320
+ return json_data
321
+
322
+ @staticmethod
323
+ def create():
324
+ """Creates Temperature Gradients in MIDAS Civil NX"""
325
+ MidasAPI("PUT", "/db/gtmp", Temperature.Gradient.json())
326
+
327
+ @staticmethod
328
+ def get():
329
+ """Get the JSON of Temperature Gradients from MIDAS Civil NX"""
330
+ return MidasAPI("GET", "/db/gtmp")
331
+
332
+ @staticmethod
333
+ def sync():
334
+ """Sync Temperature Gradients from MIDAS Civil NX to Python"""
335
+ Temperature.Gradient.temps = []
336
+ a = Temperature.Gradient.get()
337
+
338
+ if a and 'GTMP' in a:
339
+ temp_data = a.get('GTMP', {})
340
+ for element_id, element_data in temp_data.items():
341
+ element_obj = type('obj', (object,), {
342
+ 'ELEMENT': int(element_id),
343
+ 'ITEMS': element_data.get('ITEMS', [])
344
+ })()
345
+ Temperature.Gradient.temps.append(element_obj)
346
+
347
+ @staticmethod
348
+ def delete():
349
+ """Delete Temperature Gradients from MIDAS Civil NX and Python"""
350
+ Temperature.Gradient.temps = []
351
+ return MidasAPI("DELETE", "/db/gtmp")
352
+
353
+ # --------------------------------------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: midas_civil
3
- Version: 0.0.8
3
+ Version: 0.1.0
4
4
  Summary: Python library for MIDAS Civil NX
5
5
  Author: Sumit Shekhar
6
6
  Author-email: sumit.midasit@gmail.com
@@ -0,0 +1,23 @@
1
+ midas_civil/__init__.py,sha256=naIywmkJTaHytt85vRiV7Du36t2qK7liO1gEKUOS1nM,476
2
+ midas_civil/_boundary.py,sha256=cF5NIUkk3q11sDnrI1lfebLqelpPyjKF-PgAbI6UU1k,32703
3
+ midas_civil/_construction.py,sha256=W_QU0zdk7uB2SBYzqDNYbCWcg5mnVfWvrgu3PY7CHfg,19957
4
+ midas_civil/_construction_backup.py,sha256=Pj7V-NYCkkT-aMjKXfs1jKa9klsGh48UXDLwn3BLYTY,18225
5
+ midas_civil/_element.py,sha256=UbXgad_D_yNgTXWRO1zMP2hQB82BaDdMWvGymrg0L1g,18508
6
+ midas_civil/_group.py,sha256=Xk_DDyDetJ1M_90-m4XfpTxM74_6xRAdw76O7q_Qd0Y,10078
7
+ midas_civil/_load.py,sha256=Wg2Cyn7meaCkb28vQSxWi1H1slBQKXdXyoKPGvsHesQ,29557
8
+ midas_civil/_mapi.py,sha256=NImeBj8L7rwrYuaeXbaU3-UnCL4Fyp6tB1wf0UpdQp8,2354
9
+ midas_civil/_material.py,sha256=3dEIafEhdm4s0OXobXZkGYUYYdputNTQ_IyEQ1BTbeY,69478
10
+ midas_civil/_model.py,sha256=uj_nenNqNLYgwLKB6BZXEPGEByME23gVA5u3EXRZuAA,16337
11
+ midas_civil/_node.py,sha256=yj17RT3Ei7RafWQVHThjwPGUHe3DTQbuv0MwuDjCJro,3513
12
+ midas_civil/_result copy.py,sha256=siTMENLIwF_6rvydSjP9aQAWaIlt0pReiqNyDhDevGk,24290
13
+ midas_civil/_result.py,sha256=0c_lBai5ayvoOK4zD6jBDYBcqixCAljq5qJyZ4koboI,7648
14
+ midas_civil/_result_extract.py,sha256=EL8ArWXsDSJFZG0NJ6n6iZvwrY4G9cWo0HMwxz7Ir1M,3738
15
+ midas_civil/_section.py,sha256=56RWJdyvDr7Es7Is8Fxq3jPCPP57WW8ECCYZzhm6bf0,26375
16
+ midas_civil/_temperature.py,sha256=ZFs5COZh7QFe-xpWNK44u8IqlqMfaOklAo_ZOVAzFok,13047
17
+ midas_civil/_thickness.py,sha256=Mungooyfo0_JJUmjPCr25h0PSSW_TtEfcMa-hz3YGZA,3146
18
+ midas_civil/_utils.py,sha256=eymiqO8KaTKdhVY3saebqNS0BbUUmGmgw3-ELKqew0A,2611
19
+ midas_civil-0.1.0.dist-info/licenses/LICENSE,sha256=zrL4RwZC4rb-by_ZHKXwKdIwcs6ATy59TPZ9HxPHCrs,1071
20
+ midas_civil-0.1.0.dist-info/METADATA,sha256=KQmI0FJzmwZJrmL6zuxje_eoNYW3uIhA8RIvU6pBn0A,1709
21
+ midas_civil-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ midas_civil-0.1.0.dist-info/top_level.txt,sha256=_NFmrlN5V9OxJ-PAO4s_om8OA8uupXho3QqZcSsnbuI,12
23
+ midas_civil-0.1.0.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- midas_civil/__init__.py,sha256=mq1dqMgS92chPxRbKzoA7X33jpgz5y-8a_CpBvQUmJI,510
2
- midas_civil/_boundary.py,sha256=VwDgysWvcwlu2gTfEyxPuXqCp4IXKs2NTn3jUz7Brhg,32390
3
- midas_civil/_construction.py,sha256=Pj7V-NYCkkT-aMjKXfs1jKa9klsGh48UXDLwn3BLYTY,18225
4
- midas_civil/_element.py,sha256=UbXgad_D_yNgTXWRO1zMP2hQB82BaDdMWvGymrg0L1g,18508
5
- midas_civil/_group.py,sha256=8iZCIB6XEgFz4Z7QEDU3wd7t18xAtNnqetw5Ch1UOeY,10074
6
- midas_civil/_load.py,sha256=__qVQgbyfAILyoLv8eDGZ_1uMunzzDG1tUu5zWWD-oA,17213
7
- midas_civil/_mapi.py,sha256=NImeBj8L7rwrYuaeXbaU3-UnCL4Fyp6tB1wf0UpdQp8,2354
8
- midas_civil/_material.py,sha256=hlgBGL5JTN1-aDL5hXwU9lalAhzoD0pPP-8HE2jCfAs,10711
9
- midas_civil/_model.py,sha256=wbf3gmFgv0ZB4rphxr-3xLspH-WD7p6aB7PQCNGHA40,14923
10
- midas_civil/_node.py,sha256=yj17RT3Ei7RafWQVHThjwPGUHe3DTQbuv0MwuDjCJro,3513
11
- midas_civil/_result.py,sha256=siTMENLIwF_6rvydSjP9aQAWaIlt0pReiqNyDhDevGk,24290
12
- midas_civil/_result_extract.py,sha256=nYR3cYYZVogVje-Y4Y1Lh1S-lCDs_n-1MCwvkmWk6qA,2454
13
- midas_civil/_section.py,sha256=56RWJdyvDr7Es7Is8Fxq3jPCPP57WW8ECCYZzhm6bf0,26375
14
- midas_civil/_thickness.py,sha256=Mungooyfo0_JJUmjPCr25h0PSSW_TtEfcMa-hz3YGZA,3146
15
- midas_civil/_utils.py,sha256=eymiqO8KaTKdhVY3saebqNS0BbUUmGmgw3-ELKqew0A,2611
16
- midas_civil-0.0.8.dist-info/licenses/LICENSE,sha256=zrL4RwZC4rb-by_ZHKXwKdIwcs6ATy59TPZ9HxPHCrs,1071
17
- midas_civil-0.0.8.dist-info/METADATA,sha256=Xfg4B9gsHuRxpVwwbV-xX7mwnrVe1zAHD4noTzCZXzA,1709
18
- midas_civil-0.0.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- midas_civil-0.0.8.dist-info/top_level.txt,sha256=_NFmrlN5V9OxJ-PAO4s_om8OA8uupXho3QqZcSsnbuI,12
20
- midas_civil-0.0.8.dist-info/RECORD,,