Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

A simple question about SAP2000 API , Matlab

Status
Not open for further replies.

arefi

Civil/Environmental
Mar 8, 2020
1
thread801-309262
I read the topic above, but I couldn't understand what the writer did to solve his problem.
I also have built a model using SAP and saved it. Then I used the following code to open and analyze it using MATLAB interface. The problem is, I can't get any "Joint Displacement" results by API codes, and I get this error No method 'FrameForce' with matching signature found for class 'SAP2000v20.cAnalysisResults'.
.
I would REALLY appreciate any help


%% clean-up the workspace & command window

clear;

clc;



%%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 = true(); % false(); %



%% 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

%% otherwise the latest installed version of SAP2000 will be launched

SpecifyPath = false(); % true(); %



%% if the above flag is set to true, specify the path to SAP2000 below

ProgramPath = 'C:\Program Files\Computers and Structures\SAP2000 20\SAP2000.exe';



%% full path to API dll

%% set it to the installation folder

APIDLLPath = 'C:\Program Files\Computers and Structures\SAP2000 20\SAP2000v20.dll';



%% full path to the model

%% set it to the desired path of your model

ModelDirectory = 'C:\Users\User\Model';

if ~exist(ModelDirectory, 'dir')

mkdir(ModelDirectory);

end

ModelName = 'sample_bridge.sdb';

ModelPath = strcat(ModelDirectory, filesep, ModelName);



%% create API helper object

a = NET.addAssembly(APIDLLPath);

helper = SAP2000v20.Helper;

helper = NET.explicitCast(helper,'SAP2000v20.cHelper');



if AttachToInstance

%% attach to a running instance of Sap2000

SapObject = helper.GetObject('CSI.SAP2000.API.SapObject');

SapObject = NET.explicitCast(SapObject,'SAP2000v20.cOAPI');

else

if SpecifyPath

%% create an instance of the SapObject from the specified path

SapObject = helper.CreateObject(ProgramPath);

else

%% create an instance of the SapObject from the latest installed SAP2000

SapObject = helper.CreateObjectProgID('CSI.SAP2000.API.SapObject');

end

SapObject = NET.explicitCast(SapObject,'SAP2000v20.cOAPI');



%% start Sap2000 application

SapObject.ApplicationStart;

end

helper = 0;

%% create SapModel object

SapModel = NET.explicitCast(SapObject.SapModel,'SAP2000v20.cSapModel');
File = NET.explicitCast(SapModel.File,'SAP2000v20.cFile');

%% assign isotropic mechanical properties to material

RE=struct('e',zeros(100,1),'Dis',zeros(100,1));
PropMaterial = NET.explicitCast(SapModel.PropMaterial,'SAP2000v20.cPropMaterial');
ret = PropMaterial.SetMPIsotropic('C25', 2500000, 0.15, 0.00001);


%% refresh view, update (initialize) zoom

View = NET.explicitCast(SapModel.View,'SAP2000v20.cView');

ret = View.RefreshView(0, false());




%% save model

ret = File.Save(ModelPath);



%% run model (this will create the analysis model)

Analyze = NET.explicitCast(SapModel.Analyze,'SAP2000v20.cAnalyze');

ret = Analyze.RunAnalysis();

%% initialize for Sap2000 results

SapResult = zeros(2,1,'double');


%% get Sap2000 results for load case

AnalysisResults = NET.explicitCast(SapModel.Results,'SAP2000v20.cAnalysisResults');

AnalysisResultsSetup = NET.explicitCast(AnalysisResults.Setup,'SAP2000v20.cAnalysisResultsSetup');


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('DEAD');


[~, NumberResults, Obj, Elm, ACase, StepType, StepNum, U1, U2, U3, R1, R2, R3] = AnalysisResults.JointDispl('893', SAP2000v20.eItemTypeElm.ObjectElm, NumberResults, Obj, Elm, ACase, StepType, StepNum, U1, U2, U3, R1, R2, R3);

SapResult(1) = U3(1);

[ret, NumberResults, Obj, Elm, ACase, StepType, StepNum, U1, U2, U3, R1, R2, R3] = AnalysisResults.FrameForce('484', SAP2000v20.eItemTypeElm.ObjectElm, NumberResults, Obj, Elm, ACase, StepType, StepNum, U1, U2, U3, R1, R2, R3);

SapResult(2) = U1(1);



end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor