Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

SAP2000 MATLAB API, extracting displacements at a certain node.

Status
Not open for further replies.

Ahmad Fakih

Structural
Joined
Jan 12, 2020
Messages
2
Location
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!
 
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.

Part and Inventory Search

Sponsor

Back
Top