Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

SAP2000 API - External Analysis Results 1

Status
Not open for further replies.

martinrexfowler

Structural
May 6, 2019
3
Has anybody tried the API functionality to set external analysis forces to a model?

The code is fairly simple and it's returning that the forces have been correctly applied, however I can't then see any forces in the corrosponding LC in Sap2000.
 
Replies continue below

Recommended for you

I struggled with this issue for a while with no result [banghead]
I would really appreciate some help about it from anyone!
 
hello
I have a problem in this code.
it is base on the example code of Sap2000v20 in matlab.
I want to get the "modal result". but it seems there are some problem.
please help me.
thanks

%% clean-up the workspace & command window

clear;

clc;



%%set the following flag to true to attach to an existing instance of the program otherwise a new instance of the program will be started

AttachToInstance = false(); % true(); %



%% set the following flag to true to manually specify the path to SAP2000.exe

%% this allows for a connection to a version of SAP2000 other than the latest installation

%% otherwise the latest installed version of SAP2000 will be launched

SpecifyPath = false(); % true(); %



%% if the above flag is set to true, specify the path to SAP2000 below

%ProgramPath = 'C:\Program Files\Computers and Structures\SAP2000 20\SAP2000.exe';



%% full path to API dll

%% set it to the installation folder

APIDLLPath = 'C:\Program Files\Computers and Structures\SAP2000 20\SAP2000v20.dll';



%% full path to the model

%% set it to the desired path of your model

%ModelDirectory = 'C:\CSiAPIexample';

%if ~exist(ModelDirectory, 'dir')

% mkdir(ModelDirectory);

%end

%ModelName = 'API_1-001.sdb';

%ModelPath = strcat(ModelDirectory, filesep, ModelName);



%% create API helper object

a = NET.addAssembly(APIDLLPath);

helper = SAP2000v20.Helper;

helper = NET.explicitCast(helper,'SAP2000v20.cHelper');



if AttachToInstance

%% attach to a running instance of Sap2000

SapObject = helper.GetObject('CSI.SAP2000.API.SapObject');

SapObject = NET.explicitCast(SapObject,'SAP2000v20.cOAPI');

else

if SpecifyPath

%% create an instance of the SapObject from the specified path

SapObject = helper.CreateObject(ProgramPath);

else

%% create an instance of the SapObject from the latest installed SAP2000

SapObject = helper.CreateObjectProgID('CSI.SAP2000.API.SapObject');

end

SapObject = NET.explicitCast(SapObject,'SAP2000v20.cOAPI');



%% start Sap2000 application

SapObject.ApplicationStart;

end

helper = 0;



%% create SapModel object

SapModel = NET.explicitCast(SapObject.SapModel,'SAP2000v20.cSapModel');



%% initialize model

ret = SapModel.InitializeNewModel;



%% create new blank model

File = NET.explicitCast(SapModel.File,'SAP2000v20.cFile');

%%open an existing file
FileName = 'D:/test/s.sdb';
ret = File.OpenFile(FileName);


%% run model (this will create the analysis model)
Analyze = NET.explicitCast(SapModel.Analyze,'SAP2000v20.cAnalyze');

%ret = Analyze.SetRunCaseFlag('MODAL',false,true);
ret = Analyze.SetRunCaseFlag('MODAL', true);
ret = Analyze.RunAnalysis;
NumberResultsp = 0;
LoadCasep = cellstr(' ');
StepTypep = cellstr(' ');
StepNump = zeros(1,1,'double');
Period = zeros(1,1,'double');
Frequencyp = zeros(1,1,'double');
CircFreqp = zeros(1,1,'double');
EigenValuep = zeros(1,1,'double');

%modal result

AnalysisResults = NET.explicitCast(SapModel.Results,'SAP2000v20.cAnalysisResults');
Setup = NET.explicitCast(AnalysisResults.Setup,'SAP2000v20.cAnalysisResultsSetup');

[ret,NumberResultsp, LoadCasep, StepTypep, StepNump, Period, Frequencyp, CircFreqp, EigenValuep] = AnalysisResults.ModalPeriod(NumberResultsp, LoadCasep, StepTypep, StepNump, Period, Frequencyp, CircFreqp, EigenValuep)

%Open Lock
ret = SapModel.SetModelIsLocked(false);

 
The manual code is worng the step has to be set as 1, 0. ( This relates to the subject of the post which is external analysis results, not extracting information from SAP2000)
 
Hi, I think you've posted your query under the wrong thread. This thread is about external analysis results, which is when you can create an external laodcase and attribute 'results' to object stations for use in design, as sample code from the API help file as below. The solution to my probelm is the step num has to be set to 1.

'set frame external result forces at case first step

ret = SapModel.ExternalAnalysisResults.SetFrameForce("1", "EXTERNAL", 0, P, V2, V3, T, M2, M3)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor