sap interface with matlab
sap interface with matlab
(OP)
thread801-309262: SAP2000 API using MATLAB - A Simple Question
Hello, I'm taha.
I changed the profile of some members in the structure by matlab in .s2k file. Then I open it with matlab and analyse it. Now I want to get the results of analysis by matlab but I can't. Can anyone help me to do that.
Hello, I'm taha.
I changed the profile of some members in the structure by matlab in .s2k file. Then I open it with matlab and analyse it. Now I want to get the results of analysis by matlab but I can't. Can anyone help me to do that.





RE: sap interface with matlab
Nice work you've done.
I'm using this matlab code to see the results. i am using OAPI.
%--------------------- analysis results (for DEAD, LIVE,EX and Comb1) for column 1001-------------------------
ret = SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput;
ret = SapModel.Results.Setup.SetCaseSelectedForOutput('DEAD') ;
ret = SapModel.Results.Setup.SetCaseSelectedForOutput('LIVE') ;
ret = SapModel.Results.Setup.SetCaseSelectedForOutput('EX') ;
ret = SapModel.Results.Setup.SetComboSelectedForOutput('comb1') ;
NumberResults = 0;
Obj = cellstr(' ');
Elm = cellstr(' ');
ElmSta = cellstr(' ');
ObjSta=cellstr(' ');
ACase = cellstr(' ');
StepType = cellstr(' ');
StepNum = zeros(1,1,'double');
P = zeros(1,1,'double');
V2 = zeros(1,1,'double');
V3 = zeros(1,1,'double');
T = zeros(1,1,'double');
M2 = zeros(1,1,'double');
M3 = zeros(1,1,'double');
ObjectElm = 0;
[ret,NumberResults, Obj, ObjSta, Elm, ElmSta, ACase, StepType, StepNum, P, V2, V3, T, M2, M3]=SapModel.Results.FrameForce('1001', ObjectElm, NumberResults, Obj, ObjSta, Elm, ElmSta, ACase, StepType, StepNum, P, V2, V3, T, M2, M3);
P
M3
%----------------------------
Similarly you can do the coding for other results And also write your own custom design code.
Good luck!
RE: sap interface with matlab
I used the following code that you sent to me.
feature('COM_SafeArraySingleDim', 1)
feature('COM_PassSafeArrayByRef', 1)
SapObject=actxserver('SAP2000v16.SapObject');
SapObject.ApplicationStart
Sap=SapObject.SapModel;
Sap.File.OpenFile('C:\Users\ ... .s2k')
ret=Sap.Analyze.RunAnalysis
%--------------------- analysis results (for DEAD, LIVE,EX and Comb1) for column 100-------------------------
ret = Sap.Results.Setup.DeselectAllCasesAndCombosForOutput;
ret = Sap.Results.Setup.SetCaseSelectedForOutput('DEAD') ;
ret = Sap.Results.Setup.SetCaseSelectedForOutput('LIVE') ;
ret = Sap.Results.Setup.SetCaseSelectedForOutput('EX') ;
ret = Sap.Results.Setup.SetComboSelectedForOutput('comb1') ;
NumberResults = 0;
Obj = cellstr(' ');
Elm = cellstr(' ');
ElmSta = cellstr(' ');
ObjSta=cellstr(' ');
ACase = cellstr(' ');
StepType = cellstr(' ');
StepNum = zeros(1,1,'double');
P = zeros(1,1,'double');
V2 = zeros(1,1,'double');
V3 = zeros(1,1,'double');
T = zeros(1,1,'double');
M2 = zeros(1,1,'double');
M3 = zeros(1,1,'double');
ObjectElm = 0;
[ret,NumberResults, Obj, ObjSta, Elm, ElmSta, ACase, StepType, StepNum, P, V2, V3, T, M2, M3]=Sap.Results.FrameForce('100', ObjectElm, NumberResults, Obj, ObjSta, Elm, ElmSta, ACase, StepType, StepNum, P, V2, V3, T, M2, M3);
P
M3
%----------------------------
but it has a warning like following.
Warning: ActiveX - attempt to convert unsupported SAFEARRAY type failed - substituting NAN
Warning: ActiveX - attempt to convert unsupported SAFEARRAY type failed - substituting NAN
Warning: ActiveX - attempt to convert unsupported SAFEARRAY type failed - substituting NAN
Warning: ActiveX - attempt to convert unsupported SAFEARRAY type failed - substituting NAN
Warning: ActiveX - attempt to convert unsupported SAFEARRAY type failed - substituting NAN
Warning: ActiveX - attempt to convert unsupported SAFEARRAY type failed - substituting NAN
Warning: ActiveX - attempt to convert unsupported SAFEARRAY type failed - substituting NAN
P =
NaN
M3 =
NaN
Can you or someone else help me to get the results from sap by matlab correctly?
RE: sap interface with matlab
Your element name is the 1001? check it.
I'm confused Please tell me .How to make a .s2k with the MATLAB command? What matlab code do you get .s2k files from SAP ?
ret = SapModel.File.Export????
clc
clear all
feature('COM_SafeArraySingleDim', 1);
feature('COM_PassSafeArrayByRef', 1);
% create Sap2000 object
SapObject = actxserver('Sap2000v15.SapObject');
% start Sap2000 application
SapObject.ApplicationStart;
% create SapModel object
SapModel = SapObject.SapModel;
ret = SapModel.File.OpenFile('C:\Users...s2k');
% run model (this will create the analysis model)
ret = SapModel.Analyze.RunAnalysis();
%design
%start steel design
ret = SapModel.DesignSteel.StartDesign;
%out puts
%deselect all cases and combos
ret = SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput;
ret = SapModel.Results.Setup.SetCaseSelectedForOutput('DEAD') ;
NumberResults = 0;
Obj = cellstr(' ');
Elm = cellstr(' ');
ElmSta = cellstr(' ');
ObjSta=cellstr(' ');
ACase = cellstr(' ');
StepType = cellstr(' ');
StepNum = zeros(1,1,'double');
P = zeros(1,1,'double');
V2 = zeros(1,1,'double');
V3 = zeros(1,1,'double');
T = zeros(1,1,'double');
M2 = zeros(1,1,'double');
M3 = zeros(1,1,'double');
ObjectElm = 0;
[ret,NumberResults, Obj, ObjSta, Elm, ElmSta, ACase, StepType, StepNum, P, V2, V3, T, M2, M3]=SapModel.Results.FrameForce('1001', ObjectElm, NumberResults, Obj, ObjSta, Elm, ElmSta, ACase, StepType, StepNum, P, V2, V3, T, M2, M3)