Documente Academic
Documente Profesional
Documente Cultură
clear;
clc;
%% set the following flag to true to manually specify the path to SAP2000.exe
%% this allows for a connection to a version of SAP2000 other than the latest
installation
SpecifyPath = false;
%% if the above flag is set to true, specify the path to ETABS below
ModelDirectory = 'C:\CSiAPIexample';
if ~exist(ModelDirectory, 'dir')
mkdir(ModelDirectory);
end
ModelName = 'API_1-001.sdb';
a = NET.addAssembly(APIDLLPath);
helper = SAP2000v20.Helper;
helper = NET.explicitCast(helper,'SAP2000v20.cHelper');
if SpecifyPath
SapObject = helper.CreateObject(ProgramPath);
else
SapObject = helper.CreateObjectProgID('CSI.SAP2000.API.SapObject');
end
SapObject = NET.explicitCast(SapObject,'SAP2000v20.cOAPI');
helper = 0;
SapObject.ApplicationStart;
SapModel = NET.explicitCast(SapObject.SapModel,'SAP2000v20.cSapModel');
%% initialize model
ret = SapModel.InitializeNewModel;
File = NET.explicitCast(SapModel.File,'SAP2000v20.cFile');
ret = File.NewBlank;
PropMaterial = NET.explicitCast(SapModel.PropMaterial,'SAP2000v20.cPropMaterial');
PropFrame = NET.explicitCast(SapModel.PropFrame,'SAP2000v20.cPropFrame');
ModValue = NET.createArray('System.Double',8);
for i = 1 : 8
ModValue(i) = 1;
end
ModValue(1) = 1000;
ModValue(2) = 0;
ModValue(3) = 0;
ret = SapModel.SetPresentUnits(SAP2000v20.eUnits.kip_ft_F);
FrameObj = NET.explicitCast(SapModel.FrameObj,'SAP2000v20.cFrameObj');
PointObj = NET.explicitCast(SapModel.PointObj,'SAP2000v20.cPointObj');
Restraint = NET.createArray('System.Boolean',6);
for i = 1 : 4
Restraint(i) = true();
end
for i = 5 : 6
Restraint(i) = false();
end
for i = 1 : 2
Restraint(i) = true();
end
for i = 3 : 6
Restraint(i) = false();
end
View = NET.explicitCast(SapModel.View,'SAP2000v20.cView');
LoadPatterns = NET.explicitCast(SapModel.LoadPatterns,'SAP2000v20.cLoadPatterns');
PointLoadValue = NET.createArray('System.Double',6);
for i = 1 : 6
PointLoadValue(i) = 0.0;
end
PointLoadValue(3) = -10;
for i = 1 : 6
PointLoadValue(i) = 0.0;
end
PointLoadValue(3) = -17.2;
PointLoadValue(5) = -54.4;
ret = SapModel.SetPresentUnits(SAP2000v20.eUnits.kip_in_F);
%% save model
ret = File.Save(ModelPath);
Analyze = NET.explicitCast(SapModel.Analyze,'SAP2000v20.cAnalyze');
ret = Analyze.RunAnalysis();
SapResult = zeros(7,1,'double');
AnalysisResults = NET.explicitCast(SapModel.Results,'SAP2000v20.cAnalysisResults');
AnalysisResultsSetup =
NET.explicitCast(AnalysisResults.Setup,'SAP2000v20.cAnalysisResultsSetup');
for i = 1 : 7
NumberResults = 0;
Obj = NET.createArray('System.String',2);
Elm = NET.createArray('System.String',2);
ACase = NET.createArray('System.String',2);
StepType = NET.createArray('System.String',2);
StepNum = NET.createArray('System.Double',2);
U1 = NET.createArray('System.Double',2);
U2 = NET.createArray('System.Double',2);
U3 = NET.createArray('System.Double',2);
R1 = NET.createArray('System.Double',2);
R2 = NET.createArray('System.Double',2);
R3 = NET.createArray('System.Double',2);
ret = AnalysisResultsSetup.DeselectAllCasesAndCombosForOutput;
ret = AnalysisResultsSetup.SetCaseSelectedForOutput(int2str(i));
if i <= 4
[ret, NumberResults, Obj, Elm, ACase, StepType, StepNum, U1, U2, U3, R1,
R2, R3] = AnalysisResults.JointDispl(PointName2,
SAP2000v20.eItemTypeElm.ObjectElm, NumberResults, Obj, Elm, ACase, StepType,
StepNum, U1, U2, U3, R1, R2, R3);
SapResult(i) = U3(1);
else
[ret, NumberResults, Obj, Elm, ACase, StepType, StepNum, U1, U2, U3, R1,
R2, R3] = AnalysisResults.JointDispl(PointName1, SAP2000v20.eItemTypeElm.ObjectElm,
NumberResults, Obj, Elm, ACase, StepType, StepNum, U1, U2, U3, R1, R2, R3);
SapResult(i) = U1(1);
end
end
%% close Sap2000
ret = SapObject.ApplicationExit(false());
File = 0;
PropMaterial = 0;
PropFrame = 0;
FrameObj = 0;
PointObj = 0;
View = 0;
LoadPatterns = 0;
Analyze = 0;
AnalysisResults = 0;
AnalysisResultsSetup = 0;
SapModel = 0;
SapObject = 0;
IndResult = zeros(7,1,'double');
IndResult(1) = -0.02639;
IndResult(2) = 0.06296;
IndResult(3) = 0.06296;
IndResult(4) = -0.2963;
IndResult(5) = 0.3125;
IndResult(6) = 0.11556;
IndResult(7) = 0.00651;
PercentDiff = zeros(7,1,'double');
for i = 1 : 7
PercentDiff(i) = (SapResult(i) / IndResult(i)) - 1;
end
%% display results
SapResult
IndResult
PercentDiff