Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

sap interface with matlab

Status
Not open for further replies.

nasseritaha

Civil/Environmental
Jun 23, 2014
2
thread801-309262
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.
 
Replies continue below

Recommended for you

Hi taha
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!
 
Hi Miss simahr
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?
 
Do not analyze and design your model. The following code runs without any problems on my model.
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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor