Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

SAP2000 MATLAB API, extracting displacements at a certain node.

Status
Not open for further replies.

Ahmad Fakih

Structural
Jan 12, 2020
2
0
0
LB
I'm new to SAP2000 API coding,I'm trying to open an existing model and extract displacements at a certain node. My code currently opens an existing file and runs it but can't extract displacements as I'm getting this error:"First argument must be a valid .NET object".
Any idea how to extract displacements at a certain node using API on MATLAB?
My MATLAB API code is:

%% pass data to Sap2000 as one-dimensional arrays
feature('COM_SafeArraySingleDim', 1);
%% pass non-scalar arrays to Sap2000 API by reference
feature('COM_PassSafeArrayByRef', 1);
%% create Sap2000 object
SapObject = actxserver('CSI.SAP2000.API.SapObject');
%% start Sap2000 application
SapObject.ApplicationStart;
%% create SapModel object
Sap = SapObject.SapModel;
%% Hide Application, Hide <=> Visible
% SapObject.Hide;
%% open file
Sap.File.OpenFile('G:\Desktop\modeling\Output_2.sdb');
%% run model (this will create the analysis model)
Sap.Analyze.RunAnalysis();
AnalysisResults = NET.explicitCast(Sap.Results,'SAP2000v19.cAnalysisResults');
AnalysisResultsSetup = NET.explicitCast(AnalysisResults.Setup,'SAP2000v19.cAnalysisResultsSetup');
ret = AnalysisResultsSetup.DeselectAllCasesAndCombosForOutput;
ret = AnalysisResultsSetup.SetCaseSelectedForOutput('lATERAL lOAD')

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

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 = AnalysisResults.JointDispl('ALL', 1, NumberResults, Obj, 2, ACase, StepType, StepNum, U1, U2, U3, R1, R2, R3);


%% save model
Sap.File.Save('G:\Desktop\modeling\Output_2.sdb');
%% close Sap2000
SapObject.ApplicationExit(false());
SapModel = 0;
SapObject = 0;

%% END

Can you figure out what's wrong with this code?
Thanks!
 
Replies continue below

Recommended for you

The etabs api which I'm guessing is similar to the sap api you have to set the loadcases that you want to return results from, has that been done. The call should be something like:

SapModel.Results.Setup.SetCaseSelectedForOutput(case_name,True);
 
Status
Not open for further replies.
Back
Top