Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

SAP2000 API using MATLAB - A Simple Question 6

Status
Not open for further replies.

SinaPeugeot

Structural
May 30, 2010
37
Hi! I am really new to SAP2000 API and I am trying to use MATLAB to interact with SAP. I'm getting help from SAP2000 API documentation. I have built a model using SAP and saved it. Then I used the following code to open and analyze it using MATLAB interface. The problem is, I can't get any "Frame Force" results by API codes; and I get this error "No method 'FrameForce' with matching signature found for class 'Interface.Sap2000v12.cAnalysisResults'". I would REALLY appreciate any help:

feature('COM_SafeArraySingleDim', 1);
feature('COM_PassSafeArrayByRef', 1);
SapObject = actxserver('sap2000.SapObject');
SapObject.ApplicationStart;
ret = SapObject.SapModel.File.OpenFile('C:\....\1.sdb');
ret = SapObject.SapModel.Analyze.RunAnalysis();

ret = SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput;
ret = SapObject.SapModel.Results.Setup.SetCaseSelectedForOutput('DEAD');

Element = NaN;
StepNum=NaN;
NumberResults = NaN;
Obj = cellstr(' ');
ObjSta=0.5;
Elm = cellstr(' ');
ElmSta=NaN;
LoadCase = cellstr(' ');
StepType= cellstr(' ');
P = zeros(1,1,'double');
V2 = zeros(1,1,'double');
V3 = zeros(1,1,'double');
M2 = zeros(1,1,'double');
M3 = zeros(1,1,'double');
T = zeros(1,1,'double');

[ret, NumberResults, Obj, ObjSta, Elm, ElmSta, LoadCase, StepType, StepNum, P, V2, V3, T, M2, M3] =
SapModel.Results.FrameForce('1', Element, NumberResults, Obj, ObjSta, Elm, ElmSta, LoadCase, StepType, StepNum, P, V2, V3,
T, M2, M3)

 
Replies continue below

Recommended for you

Hi Osquro
I'm trying to run a long time analyzing the movements of a model of a building and set up SAP200, but it appears error 'Warning: ActiveX - Attempt to convert unsupported type SAFEARRAY failed - substituting NAN', and not how to solve it. I would greatly appreciate your help
Here I post a piece of code, dode think this error

NumberResults = zeros (1.1, 'double');
Obj = cellstr ('');
Elm = cellstr ('');
Cellstr ACase = ('');
Cellstr StepType = ('');
StepNum = zeros (1.1, 'double');
Group = 2;
U11 = zeros (1.1, 'double');
U22 = zeros (1.1, 'double');
U33 = zeros (1.1, 'double');
R11 = zeros (1.1, 'double');
R22 = zeros (1.1, 'double');
R33 = zeros (1.1, 'double');

After he indicated that I run the analysis and the type of load:
I write this and I get the error mentioned.

[ret, NumberResults, Obj, Elm, ACase, StepType, StepNum, U11, U22, U33, R11, R22, R33] = SapModel.Results.JointDispl ('Group1' Group, NumberResults, Obj, Elm, ACase, StepType, StepNum, U11, U22, U33, R11, R22, R33
 
I will run run code tonight. In the mean time, try this:
- In the line: NumberResults = zeros (1.1, 'double'); all the arguments must be separated by comas (1, 1, 'double').
- In the line: Obj = cellstr (''); use a space as an argument (' ')
- Did you use the methods .DeselectAllCasesAndCombosForOutput and .SetCaseSelectedForOutput before retrieve results?
 
Hi Osquro

You did everything you told me, and I run, but is only an offset, the following is not me. I write the code:
This is the callback to analyze Sap2000

Code:
ret = SapModel.File.Save('G:\PROYECTO SOPORTE\EDIFICIO 350.sdb');
        
       ret = SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput;

        ret = SapModel.Results.Setup.SetCaseSelectedForOutput('DEAD');
         ret = SapModel.Analyze.CreateAnalysisModel
        ret = SapModel.Analyze.RunAnalysis()
 NumberResults = 0;
           Obj = {' '};
           Elm = {' '};
           LoadCase = {' '};
           StepType = {' '};
           StepNum = zeros(1,1,'double');
           U1 =zeros(1,1,'double');
         
           U2 =zeros(1,1,'double');
           
           U3 = zeros(1,1,'double');
        
           R1 = zeros(1,1,'double');
        
           R2 = zeros(1,1,'double');
    
           R3 = zeros(1,1,'double');
          
           ObjectElm = 0;
     
 
    for i=1:5151
       [ret,NumberResults, Obj, Elm, LoadCase, StepType, StepNum, U1, U2, U3, R1, R2, R3] = SapModel.Results.JointDispl(num2str(i), ObjectElm, NumberResults, Obj, Elm, LoadCase, StepType, StepNum, U1, U2, U3, R1, R2, R3) 

end


Muchas Gracias
 
Hi teffaSapMatlab. I am really sorry for my late reply. For some reason, I did not get the notification.
Actually, my problem was something else. I was trying to extract results for a load combination and it was showing the same error as yours. But when I changed my code to get the results for a specific load case, it worked.
I guess your problem is something different. My suggestion is to try extracting joint displacement results for a single node first, instead of using the 'for loop'. If you succeed, only then go for the loops. I have posted my code below. I hope it will help you customizing your one. Thanks.

CODE:

% Run model (this will create the analysis model)
ret = SapModel.Analyze.RunAnalysis();

% Roof Deflection of left column

[ret, PointName1, PointName2] = SapModel.FrameObj.GetPoints(FrameName2, PointName1, PointName2);

NumberResults = 0;
Obj = cellstr(' ');
Elm = cellstr(' ');
ACase = cellstr(' ');
StepType = cellstr(' ');
StepNum = zeros(1,1,'double');
U1 = zeros(1,1,'double');
U2 = zeros(1,1,'double');
U3 = zeros(1,1,'double');
R1 = zeros(1,1,'double');
R2 = zeros(1,1,'double');
R3 = zeros(1,1,'double');
ObjectElm = 0;
Def = zeros(1,1,'double');

ret = SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput;

[ret, NumberResults, Obj, Elm, ACase, StepType, StepNum, U1, U2, U3, R1, R2, R3] = SapModel.Results.JointDispl(PointName2, ObjectElm, NumberResults, Obj, Elm, ACase, StepType, StepNum, U1, U2, U3, R1, R2, R3);

Def = U1;

%END


 
Hi Osquro. I am trying to get the design summary results for frame elements. I succeeded to obtain the beam results (using SapModel.DesignConcrete.GetSummaryResultsBeam). But for some reason I couldn't do the same in case of columns (using SapModel.DesignConcrete.GetSummaryResultsColumn). I got an error 'Error using Interface.SAP2000v15._cDesignConcrete/GetSummaryResultsColumn
Invoke Error, Dispatch Exception: Exception occurred.'
I have recently started using SAP API and I am a novice in Matlab. Would you please let me know what I am doing wrong? I have posted my code below. Thanks in advance. TC.

CODE

% Run model (this will create the analysis model)
ret = SapModel.Analyze.RunAnalysis();

% Start concrete design
ret = SapModel.DesignConcrete.StartDesign;

% Get summary result data

NumberItems = 0;
FrameName = cellstr(' ');
MyOption = 2;
Location = zeros(1,1,'double');
PMMCombo = cellstr(' ');
PMMArea = zeros(1,1,'double');
PMMRatio = zeros(1,1,'double');
VmajorCombo = cellstr(' ');
AVmajor = zeros(1,1,'double');
VminorCombo = cellstr(' ');
AVminor = zeros(1,1,'double');
ErrorSummary = cellstr(' ');
WarningSummary = cellstr(' ');
Object = 0;

[ret, NumberItems, FrameName, MyOption, Location, PMMCombo, PMMArea, PMMRatio, VmajorCombo, AVmajor, VminorCombo, AVminor, ErrorSummary, WarningSummary] = SapModel.DesignConcrete.GetSummaryResultsColumn('1', NumberItems, FrameName, MyOption, Location, PMMCombo, PMMArea, PMMRatio, VmajorCombo, AVmajor, VminorCombo, AVminor, ErrorSummary, WarningSummary, Object);

%END
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor