{??PSafeArray}OleVariant

Giganews Newsgroups
Subject:{??PSafeArray}OleVariant
Posted by: Carlo Masotti
Date:Wed, 23 Sep 2009

I'm trying to write an OLE client for SolidEdge starting from a VB program that works well.
I've find few messages from guys who have the same problem but using different servers. Probably it is a problem that Delphi has using  PSafeArray parameters.

The VB script declare:

Dim objEPProfile as SolidEdgePart.Profile
Dim objEPProfArray(1 to 3) as SolidEdgePart.Profile

and call the procedure

set objEPProfile = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp := objDoc.RefPlanes(1))
set objEPProfArray(1) = objEPProfile
set objModel = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles := 1, _
  ProfileArray := objEPProfArray, ProfilePlaneSide := igSymmetric, _
  ExtrusionDistance := 0.1)

and it works!

My TLB is

Models = dispinterface
    ['{49852F8C-A403-11CE-818E-0800363A1E02}']
  ..........
    function AddFiniteExtrudedProtrusion(NumberOfProfiles: Integer;
                                        var ProfileArray: {??PSafeArray}OleVariant;
                                        ProfilePlaneSide: FeaturePropertyConstants;
                                        ExtrusionDistance: Double;
                                        KeyPointOrTangentFace: OleVariant;
                                        KeyPointFlags: OleVariant; FromSurfOrRefPlane: OleVariant;
                                        ToSurfOrRefPlane: OleVariant): Model; dispid 233;
I declare

Var
    profile:variant;
    ProfileArray: OleVariant;

and I call the procedure with

ProfileArray:= VarArrayCreate([0, 0], varDispatch);
ProfileArray[0] := profile;
docPart.Models.AddFiniteExtrudedProtrusion(1, ProfileArray, igLeft, 0.05, 0, 0, 0, 0);

I tried modifing it many many times, using PSafeArray and variant in all the possible combinations, but always with the same bad result: I always get the same exception
EOLESysError  that explains that the types aren't compatible.

Does anyone know how VB maps in memory
Dim objEPProfArray(1 to 3) as SolidEdgePart.Profile , and how is it possible to reproduce the same memory map in Delphi???

Thanks

Replies