Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

ETABS API Python "Analysis Result"

Status
Not open for further replies.

eminsade

Civil/Environmental
Dec 18, 2023
1
Hello, I am connecting to etabse and using the combination I chose. I want to write a code that will get "frame forces" data from the "analysis result" section. I wrote a code, it connects to etabse and pulls the combinations correctly, but the frame force data does not appear. Can you help me where is my mistake? Did I share the code and its output?
import comtypes.client

class EtabsColumnForcesConsole:
def __init__(self):
self.ETABSObject = None
self.SapModel = None
self.connected = False

def connect_to_etabs(self):
try:
self.ETABSObject = comtypes.client.GetActiveObject("CSI.ETABS.API.ETABSObject")
self.SapModel = self.ETABSObject.SapModel
self.connected = True
except Exception as e:
print("Etabs connection error:", str(e))
self.connected = False

self.update_connection_status()

def update_combination_names(self):
combinations = self.get_etabs_combinations()
if combinations:
print("Combinations:", combinations)

def get_etabs_combinations(self):
try:
ret_combinations = self.SapModel.RespCombo.GetNameList()
combination_names = [item for item in ret_combinations[1]]
return combination_names
except Exception as e:
print("ETABS connection error:", str(e))
return None

def update_connection_status(self):
if self.connected:
print("Connection Status: Connected")
else:
print("Connection Status: Not Connected")

def get_column_forces_data(self, combination):
if not self.connected:
print("Warning: No connection to ETABS.")
return

try:
print("Selected Combination:", combination)
self.SapModel.Results.Setup.SetComboSelectedForOutput(combination, True)
print("Combination successfully selected")

ret_column_forces = self.SapModel.Results.FrameForce("ALL", 0, 0, [], [], [], [], [], [], [], [], [], [], [], [], [])
print("FrameForce data successfully retrieved")

# Print the retrieved data
print("Retrieved Data:")
for i, load_case in enumerate(ret_column_forces[7]):
print(f"Load Case: {load_case}, P: {ret_column_forces[8]}, V2: {ret_column_forces[9]}, V3: {ret_column_forces[10]}, T: {ret_column_forces[11]}, M2: {ret_column_forces[12]}, M3: {ret_column_forces[13]}")

except Exception as e:
print("Column Forces data retrieval error:", str(e))
print("Warning: An error occurred while retrieving Column Forces data.")

def run(self):
self.connect_to_etabs()
self.update_combination_names()
combination = input("Combination Name: ")
self.get_column_forces_data(combination)


if __name__ == "__main__":
app = EtabsColumnForcesConsole()
app.run()
OUTPUT:
Connection Status: Connected
Combinations: ['USTX', 'USTY', 'DUSTX', 'DUSTY', 'DALTX', 'DALTY', 'DUSTVTABANX', 'DUSTVTABANY', 'EDZ', 'GT', 'AGIRLIK', 'QT', '14G16Q16S', '14G16Q', 'USTSUNEKDEP1', 'USTSUNEKDEP2', 'USTSUNEKDEP3', 'USTSUNEKDEP4', 'USTGEVREKDEP1', 'USTGEVREKDEP2', 'USTGEVREKDEP3', 'USTGEVREKDEP4', 'ALTSUNEKDEP1', 'ALTSUNEKDEP2', 'ALTSUNEKDEP3', 'ALTSUNEKDEP4', 'ALTSUNEKDEP5', 'ALTSUNEKDEP6', 'ALTSUNEKDEP7', 'ALTSUNEKDEP8', 'ALTSUNEKDEP9', 'ALTSUNEKDEP10', 'ALTSUNEKDEP11', 'ALTSUNEKDEP12', 'ALTSUNEKDEP13', 'ALTSUNEKDEP14', 'ALTSUNEKDEP15', 'ALTSUNEKDEP16', 'ALTGEVREKDEP1', 'ALTGEVREKDEP2', 'ALTGEVREKDEP3', 'ALTGEVREKDEP4', 'ALTGEVREKDEP5', 'ALTGEVREKDEP6', 'ALTGEVREKDEP7', 'ALTGEVREKDEP8', 'ALTGEVREKDEP9', 'ALTGEVREKDEP10', 'ALTGEVREKDEP11', 'ALTGEVREKDEP12', 'ALTGEVREKDEP13', 'ALTGEVREKDEP14', 'ALTGEVREKDEP15', 'ALTGEVREKDEP16', 'USTENVEGEVREK', 'USTENVESUNEK', 'ALTENVEGEVREK', 'ALTENVESUNEK']
Combination Name: 14g16q
Selected Combination: 14g16q
Combination successfully selected
FrameForce data successfully retrieved
Retrieved Data:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor