Professional Documents
Culture Documents
PDF Etabs Oapi - Compress
PDF Etabs Oapi - Compress
PDF Etabs Oapi - Compress
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(
comtypes.client.GetActiveObject("CSI.ETABS.API.ETABSObject")
"CSI.ETABS.API.ETABSObject")
else:
#create API helper object
helper = comtypes.client.CreateObject('ETABS2016.Helper')
comtypes.client.CreateObject('ETABS2 016.Helper')
helper = helper.QueryInterface(comtypes.gen.ETABS2016.cHelper)
helper.QueryInterface(comtypes.gen.E TABS2016.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.ET
helper.CreateObjectProgID("CSI.ETABS.API.ETABSObject")
ABS.API.ETABSObject")
except (OSError, comtypes.COMError):
print("Cannot
sys.exit(-1) start a new instance of the program.")
#initialize model
SapModel.InitializeNewModel()
Etabs oapi
'R1', '3', 'Global')
[PointName1,
PointName2) PointName2, ret] = SapModel.FrameObj.GetPoints(FrameName1, PointName1,
ret = SapModel.PointObj.SetRestraint(PointName1, Restraint)
'Local')
Page 3
Etabs oapi
ret = SapModel.FrameObj.SetLoadDistributed(FrameName2, '5', 1, 2, 0, 1, -2, -2,
'Local')
#save model
ret = SapModel.File.Save(ModelPath)
Etabs oapi
Elm, ACase, StepType, StepNum, U1, U2, U3, R1, R2, R3)
ProgramResult[i] = U3[0]
else:
[NumberResults, Obj, Elm, ACase, StepType, StepNum, U1, U2, U3, R1, R2,
R3, ret] = SapModel.Results.JointDispl(PointName1, ObjectElm, NumberResults, Obj,
Elm, ACase, StepType, StepNum, U1, U2, U3, R1, R2, R3)
ProgramResult[i] = U1[0]
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()
SapModel.Results.Setup.Deselect AllCasesAndCombosForOutput()
ret = SapModel.Results.Setup.SetCaseSelectedForOutput(str(i
SapModel.Results.Setup.SetCaseS electedForOutput(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]
PercentDiff = [0,0,0,0,0,0,0]
Page 5
Etabs oapi
for i in range(0,7):
PercentDiff[i] = (ProgramResult[i] / IndResult[i]) - 1
#display results
for i in range(0,7):
print()
print(ProgramResult[i])
print(IndResult[i])
print(PercentDiff[i])
print(ProgramResult1[i])
Page 6