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 cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matlab crash when using SAP API

Status
Not open for further replies.

xantis85

Civil/Environmental
Joined
Feb 19, 2016
Messages
2
Location
IT
Hello to everyone,
I got a problem when trying to retrieve the displacement history step-by-step dor node 282 using matlab. I'm using Matlab 2015a and SAP2000 v.17.2.0. The problem is that matlab crashes and I don't know what's going wrong, I'm very new to OAPI.

I'm using the following code to run analyses:
clear all;clc;
ProgramPath = 'J:\SAP\SAP2000.exe';
feature('COM_SafeArraySingleDim', 1);
feature('COM_PassSafeArrayByRef', 1);
%% create OAPI helper object
helper = actxserver('Sap2000v17.helper');
helper = helper.invoke('cHelper');
%% create Sap2000 object
SapObject = helper.CreateObject(ProgramPath);

%% start Sap2000 application
SapObject.ApplicationStart;
SapModel = SapObject.SapModel;
ret = SapModel.InitializeNewModel;
FileName = ModelPath;
ret = SapModel.File.OpenFile(FileName);

ret = SapModel.Analyze.RunAnalysis();
ret = SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput;
ret = SapModel.Results.Setup.SetCaseSelectedForOutput('SismaX');
ret = SapModel.Results.Setup.SetOptionModalHist(2);
NumberResults = 0;
ObjectElm = 0;
Obj = cellstr(' ');
Elm = cellstr(' ');
LoadCase = cellstr(' ');
StepType = cellstr('Time');
StepNum = reshape(0:200,201,1);
U1 = reshape(0:200,201,1);
U2 = reshape(0:200,201,1);
U3 = reshape(0:200,201,1);
R1 = reshape(0:200,201,1);
R2 = reshape(0:200,201,1);
R3 = reshape(0:200,201,1);

Until this part, the code works. When adding the followin string:

[ret, NumberResults, Obj, Elm, LoadCase, StepType, StepNum, U1, U2, U3, R1, R2, R3] = SapModel.Results.JointAccAbs('282', ObjectElm, NumberResults, Obj, Elm, LoadCase, StepType, StepNum, U1, U2, U3, R1, R2, R3);

Matlab crashes

Anyone could help me? every suggestion would be very appreciated.
Thanks in advance
Marco.



 
The program correctly run the analyses when not using matlab.
 
I have the same problem. I run my code and it works just fine. But anther day,I run the same code and MATLAB crushes after several loops. It is random!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top