How to use Sap2000 api Matlab ?

14 vues (au cours des 30 derniers jours)
Ali
Ali le 10 Nov 2014
Hello
I work on a project, and I need programming with Matlab and Run in Sap2000. But when I use code one message happen: "Warning: ActiveX - attempt to convert unsupported SAFEARRAY type failed - substituting NAN "
how I can solve that?
my code:
clc; clear all;
x=(0.645*10^-4)+rand(10,1)*(50-0.645)*10^-4;
%% Start Sap2000
feature('COM_SafeArraySingleDim', 1); feature('COM_PassSafeArrayByRef', 1);
SapObject = actxserver('Sap2000v16.SapObject');
SapObject.ApplicationStart; ret=SapObject.SapModel.InitializeNewModel; ret=SapObject.SapModel.File.OpenFile('C:\Users\ali\Desktop\EXAM\EXAM01.sdb');
% SapObject.ApplicationStart(2, 1, 'C:\Users\ali\Desktop\EXAM\EXAM01.sdb'); SapModel= SapObject.SapModel;
%% Modify the sections area
for k=1:1:10
ret=SapModel.PropFrame.SetChannel( num2str(k) , 'folad' , x(k,1)^0.5 , x(k,1)^0.5 , 0.9*x(k,1)^0.5 , 0.4*x(k,1)^0.5 );
end
%% Save new model
ret=SapModel.File.Save('C:\Users\ali\Desktop\EXAM\EXAM01.sdb');
%% Run analisis
ret=SapObject.SapModel.Analyze.RunAnalysis;
%% Get Stress from Sap2000
ret = SapObject.SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput; ret = SapObject.SapModel.Results.Setup.SetCaseSelectedForOutput('DEAD');
Name = '1'; Element = 1; NumberResults = 0; Obj = cellstr(' '); ObjSta = zeros(1,1,'double'); Elm = cellstr(' '); ElmSta = zeros(1,1,'double'); LoadCase = 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');
[ret, NumberResults, Obj, ObjSta, Elm, ElmSta, LoadCase, StepType, StepNum, P, V2, V3, T, M2, M3] = SapObject.SapModel.Results.FrameForce(Name, Element, NumberResults, Obj, ObjSta, Elm, ElmSta, LoadCase, StepType, StepNum, P, V2, V3, T, M2, M3);
disp(P);
  1 commentaire
Osman TUNCA
Osman TUNCA le 25 Juin 2015
Hi Where did u from this codes? I can not find orjinal document

Connectez-vous pour commenter.

Réponses (1)

said toghani
said toghani le 5 Nov 2019
hello you define parameters in wrong way.

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by