-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_etabs_model.py
87 lines (77 loc) · 2.8 KB
/
run_etabs_model.py
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
80
81
82
83
84
85
86
87
import comtypes.client
import pythoncom
import json
from pathlib import Path
def create_etabs_model():
# Initialize ETABS model
program_path=r"C:\Program Files\Computers and Structures\ETABS 22\ETABS.exe"
pythoncom.CoInitialize()
try:
helper = comtypes.client.CreateObject("ETABSv1.Helper")
helper = helper.QueryInterface(comtypes.gen.ETABSv1.cHelper)
EtabsEngine = helper.CreateObject(program_path)
EtabsEngine.ApplicationStart()
EtabsObject = EtabsEngine.SapModel
EtabsObject.InitializeNewModel(9) # Set units to mm
EtabsObject.File.NewBlank()
finally:
pythoncom.CoUninitialize()
# Create joints
input_json = Path.cwd() / "inputs.json"
with open(input_json) as jsonfile:
data = json.load(jsonfile)
nodes, lines = data[:]
# Create nodes
for id, node in nodes.items():
ret, _ = EtabsObject.PointObj.AddCartesian(
node["x"], node["y"], node["z"], " ", str(id)
)
# Create members
MATERIAL_CONCRETE = 2
ret = EtabsObject.PropMaterial.SetMaterial("CONC", MATERIAL_CONCRETE)
ret = EtabsObject.PropMaterial.SetMPIsotropic("CONC", 30000, 0.2, 0.0000055)
section_name = "300x300 RC"
ret = EtabsObject.PropFrame.SetRectangle(section_name, "CONC", 300, 300)
for id, line in lines.items():
point_i = line["node_i"]
point_j = line["node_j"]
ret, _ = EtabsObject.FrameObj.AddByPoint(
str(point_i), str(point_j), str(id), section_name, "Global"
)
# Add rigid supports
list_nodes = [1, 2, 5, 6]
for node_id in list_nodes:
ret = EtabsObject.PointObj.SetRestraint(str(node_id), [1, 1, 1, 1, 1, 1])
EtabsObject.View.RefreshView(0, False)
# Create the model and run the analysis
file_path = Path.cwd() / "etabsmodel.edb"
EtabsObject.File.Save(str(file_path))
EtabsObject.Analyze.RunAnalysis()
# Get the reaction loads
load_case = "Dead"
ret = EtabsObject.Results.Setup.DeselectAllCasesAndCombosForOutput()
reactions_list = list()
ret = EtabsObject.Results.Setup.SetCaseSelectedForOutput(load_case)
for node in list_nodes:
*_, U1, U2, U3, R1, R2, R3, ret = EtabsObject.Results.JointReact(
str(node), 0, 0
)
reaction = {
"Node": str(node),
"LoadCase": load_case,
"U1": U1[0],
"U2": U2[0],
"U3": U3[0],
"R1": R1[0],
"R2": R2[0],
"R3": R3[0],
}
reactions_list.append(reaction)
# Save the output in a JSON
output = Path.cwd() / "output.json"
with open(output, "w") as jsonfile:
json.dump(reactions_list, jsonfile)
ret = EtabsEngine.ApplicationExit(False)
return ret
if __name__ == "__main__":
create_etabs_model()