Unspecified error when calling AddFiniteExtrudedProtrusion ST9 API

Experimenter
Experimenter

My code is in Delphi, but I think .Net or VB users can interpret.

 

I have written a short program in Delphi RAD 2010 and am getting an unspecified error in the AddFiniteExtrudedProtrusion method of Models.  The code below works up to the last statement.

 

Procedure DrawProfile;

var

   ObjDocs       : Documents;

   objPart       : PartDocument;

   objProfSets   : ProfileSets;

   objProfSet    : ProfileSet;

   objProfs      : Profiles;

   objProf       : Profile;

   objRefPlns    : RefPlanes;

   objRels2D     : Relations2D;

   objRel2D      : Relation2D;

   objLines2D    : Lines2D;

   objLine2D     : Line2D;

   objModels     : Models;

   objModel      : Model;

   ProfileArray  : OleVariant;

begin

   StartSE;

   objDocs:=objApp.Documents;

   objPart:=objApp.Documents.Add('SolidEdge.PartDocument', TempDoc) as Partdocument;

   objProfSets:=objPart.ProfileSets;

   objProfSet:=objProfSets.Add;

   objProfs:=objProfSet.Profiles;

   objRefPlns:=objPart.RefPlanes;

   objProf:=objProfs.Add(objRefPlns.Item(3));

   objLines2D:=objProf.Lines2d;

   objLine2D:=objLines2D.AddBy2Points(0,0,1,0);

   objLine2D:=objLines2D.AddBy2Points(1,0,1,1);

   objLine2D:=objLines2D.AddBy2Points(1,1,0,1);

   objLine2D:=objLines2D.AddBy2Points(0,1,0,0);

 

   objRels2D:= Relations2D(objProf.Relations2d);

   objRel2D:=objRels2D.AddKeypoint(objLines2D.Item(1),igLineEnd, objLines2D.Item(2),igLineStart,true);

   objRel2D:=objRels2D.AddKeypoint(objLines2D.Item(2),igLineEnd, objLines2D.Item(3),igLineStart,true);

   objRel2D:=objRels2D.AddKeypoint(objLines2D.Item(3),igLineEnd, objLines2D.Item(4),igLineStart,true);

   objRel2D:=objRels2D.AddKeypoint(objLines2D.Item(4),igLineEnd, objLines2D.Item(1),igLineStart,true);

 

   objProf.End_(igClosed);

   Dist:=1;

   ProfileArray:=objProfs.Add(objProf) as Profiles;

   objModels:=objPart.Models;

      // The below statement will run, but gives an unspecified error

   objModel:=objModels.AddFiniteExtrudedProtrusion(1, ProfileArray, igRight ,

                                                      Dist, EmptyParam,EmptyParam,EmptyParam,EmptyParam);

end;