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

2 visualizzazioni (ultimi 30 giorni)
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.

Risposte (0)

Categorie

Scopri di più su Use COM Objects in MATLAB in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by