AnsweredAssumed Answered

Trying to select a plane

Question asked by Alan Jordan on Feb 3, 2015
Latest reply on Feb 3, 2015 by Keith Rice

I am not writing this in any of the example languages shown in the API help, but am able to interpret most of the arguments needed.  I am new to the API and am trying to select a plane to use for a sketch.  I am using the ModelDocExtension.SelectByID method.  I am using OLE in Delphi (please don't stop reading) I have been able to get the 'SldWorks.Application' as an active OLEObject, get a new part and set a variant to ModelDocExtension, but when I call ModelDocExtension.SelectByID('Front Plane', 'PLANE, 0,0,0,false,0, ???).  The ??? is callout in the API help and I am not sure what that is.  I have assumed it is the variable I have assigned to the ActiveDoc which is my NewPart. 

 

When I tun the code, SolidWorks starts if not already running, a new part is created and the Front Plane is selected, then there is an exception thrown.

 

Here is the code:

var

  FSldWorks :  Variant;
  FSldPart  :  Variant;
  FModDoc2  :  Variant;
  FModDocExt:  Variant;

   try

      FSldWorks:=GetActiveOLEObject('SldWorks.Application');

   except

      FSldWorks:=CreateOLEObject('SldWorks.Application');

   end;

   FModDoc2:=FSldWorks.NewPart;

   FModDocExt:=FModDoc2.Extension;

   FSldPart:=FSldWorks.ActiveDoc;

   FModDocExt.SelectByID('Front Plane','PLANE',0,0,0, false,0, FSldPart);

Outcomes