×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

sap interface with matlab

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.

RE: sap interface with matlab

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!

RE: sap interface with matlab

(OP)
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?

RE: sap interface with matlab

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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources