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!

SAP2000 API using MATLAB - Set Stage Definitions

Status
Not open for further replies.

pasqualesmaldini

Civil/Environmental
Nov 17, 2015
1
Dear users,
I'm using MATLAB r2014b API connection with SAP2000 v17.3.
I found some problem using the "SetStageDefinitions_1" function.
I tried to use this script, according to OAPI Documentation.

%% clean-up the workspace & command window
clear all
clc

% set the installation folder
ProgramPath='C:\Program Files (x86)\Computers and Structures\SAP2000 17\sap2000.exe';

%% pass data to Sap2000 as one-dimensional arrays
feature('COM_SafeArraySingleDim', 1);

%% pass non-scalar arrays to Sap2000 API by reference
feature('COM_PassSafeArrayByRef', 1);

%% create OAPI helper object
helper=actxserver('Sap2000v17.helper');
helper=helper.invoke('cHelper');

%% create Sap2000 object
SapObject=helper.CreateObject(ProgramPath);

%% start Sap2000 application
SapObject.ApplicationStart;

%% create SapModel object
SapModel=SapObject.SapModel;

%% initialize model
ret=SapModel.InitializeNewModel;

%% create model from template
ret=SapModel.File.New2DFrame(0, 2, 144, 2, 288);

%% add static nonlinear staged load case
ret=SapModel.LoadCases.StaticNonlinearStaged.SetCase...
('ACASE1');

MyDuration=zeros(2,1);

MyDuration(1,1)=30;
MyOutput=true;
MyOutputName={'ST1'};
MyComment={'Build structure'};

ret=SapModel.LoadCases.StaticNonlinearStaged.SetStageDefinitions_1...
('ACASE1', 1, MyDuration, MyOutput, MyOutputName, MyComment)

%% close Sap2000
ret=SapObject.ApplicationExit(false());
SapModel=0;
SapObject=0;

I received the following error from MATLAB an of course it's not still working on SAP.

Error using
Interface.2CE898D9_F0EA_4961_970F_D8A5FC72BC89/SetStageDefinitions_1
Error: Type mismatch, argument 3

Error in TEST_SETSTAGEDATA (line 44)
ret=SapModel.LoadCases.StaticNonlinearStaged.SetStageDefinitions_1...

I checked it on internet ad I understood that the problem is is "MyOutput" variable. I defined it as a logical value, comparing the Boolean one of VisualBasic language but it doesn't work.

Does anyone know how to help me and solve this problem?
Thank you to everyone in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor