How do you invoke a method that takes SafeArray(handle) as an argument?

조회 수: 2 (최근 30일)
Geoff Olynyk
Geoff Olynyk 2012년 4월 23일
댓글: Andrea Carignano 2018년 4월 26일
I have a COM object objModels, for which I'm trying to call a method AddFiniteRevolvedProtrusion(). But it always fails because one of the input arguments for this method is a SafeArray of another type of COM object. (This is all for controlling Siemens Solid Edge ST2 Ordered Part, for reference.)
Here is the line of code:
% Revolve objProfile around objRefAxis:
objRevolve = objModels.AddFiniteRevolvedProtrusion( ...
int32(1), ... % int NumberOfProfiles
objProfile, ... % ref Array ProfileArray
objRefAxis, ... % RefAxis ReferenceAxis
'igLeft' , ... % FeaturePropertyConstants ProfilePlaneSide
2.0 * pi) ; % double AngleofRevolution
It's the second argument that fails:
Error using Interface.Solid_Edge_Part_Type_Library.Models/AddFiniteRevolvedProtrusion
Error: Type mismatch, argument 2
If I query the methods available on objModels using invoke(), it reveals the following:
invoke(objModels)
AddFiniteRevolvedProtrusion = handle AddFiniteRevolvedProtrusion(handle, int32, SafeArray(handle), handle, FeaturePropertyConstants, double, Variant(Optional))
So you can see it wants a SafeArray of handles for the second argument. So I try passing it an array of my objProfile objects as follows:
% Create an array of profile objects:
aProfiles(2) = objProfile ;
% Revolve the profile (in aProfiles) around objRefAxis:
objRevolve = objModels.AddFiniteRevolvedProtrusion( ...
int32(1), ... % int NumberOfProfiles
aProfiles, ... % ref Array ProfileArray
objRefAxis, ... % RefAxis ReferenceAxis
'igLeft' , ... % FeaturePropertyConstants ProfilePlaneSide
2.0 * pi) ; % double AngleofRevolution
and this time it fails with:
No method 'AddFiniteRevolvedProtrusion' with matching signature found for class
'Interface.Solid_Edge_Part_Type_Library.Models'.
Error in revolveCircleTest (line 103)
objRevolve = objModels.AddFiniteRevolvedProtrusion( ...
Unexpected error status flag encountered. Resetting to proper state.
Which is just weird (especially that last bit about "Unexpected error status flag"). Any suggestions? Thanks in advance!
Note that this thread is roughly the same problem as my other thread here, but this one is expressed more clearly. Also see Stack Overflow here.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by