Professional Documents
Culture Documents
Etabs Oapi
Etabs Oapi
import os
import sys
import comtypes.client
#set the following flag to True to attach to an existing instance of the program
#otherwise a new instance of the program will be started
AttachToInstance = False
#set the following flag to True to manually specify the path to ETABS.exe
#this allows for a connection to a version of ETABS other than the latest
installation
#otherwise the latest installed version of ETABS will be launched
SpecifyPath = False
#if the above flag is set to True, specify the path to ETABS below
ProgramPath = "C:\Program Files\Computers and Structures\ETABS 2016\ETABS.exe"
if AttachToInstance:
#attach to a running instance of ETABS
try:
#get the active ETABS object
myETABSObject = comtypes.client.GetActiveObject("CSI.ETABS.API.ETABSObject")
else:
#create API helper object
helper = comtypes.client.CreateObject('ETABS2016.Helper')
helper = helper.QueryInterface(comtypes.gen.ETABS2016.cHelper)
if SpecifyPath:
try:
#'create an instance of the ETABS object from the specified path
myETABSObject = helper.CreateObject(ProgramPath)
except (OSError, comtypes.COMError):
print("Cannot start a new instance of the program from " + ProgramPath)
sys.exit(-1)
Page 1
Etabs oapi
else:
try:
#create an instance of the ETABS object from the latest installed ETABS
myETABSObject = helper.CreateObjectProgID("CSI.ETABS.API.ETABSObject")
except (OSError, comtypes.COMError):
print("Cannot start a new instance of the program.")
sys.exit(-1)
#initialize model
SapModel.InitializeNewModel()
#save model
ret = SapModel.File.Save(ModelPath)
for i in range(0,7):
NumberResults = 0
PointElm =''
Obj = []
Elm = []
ACase = []
StepType = []
StepNum = []
F1 = []
F2 = []
F3 = []
M1 = []
M2 = []
M3 = []
ObjectElm = 1
ret = SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput()
ret = SapModel.Results.Setup.SetCaseSelectedForOutput(str(i + 1))
[NumberResults, Obj, Elm, PointElm, ACase, StepType, StepNum, F1, F2, F3, M1,
M2, M3, ret] = SapModel.Results.FrameJointForce("1", ObjectElm, NumberResults, Obj,
Elm, PointElm, ACase, StepType, StepNum, F1, F2, F3, M1, M2, M3)
ProgramResult1[i] = F3[0]
#display results
for i in range(0,7):
print()
print(ProgramResult[i])
print(IndResult[i])
print(PercentDiff[i])
print(ProgramResult1[i])
Page 6