Reply

api function for getting closest point on a face?

hi solid edge forum,

 

is there a way to get the point on a face (or edge) which is nearest to some arbitrary point? i feel like this is a common feature of many CAD apis, but was not able to find something similar in the SE documentation.

 

i did try using GetParamAtPoint hoping that it would return the nearest valid face parameters, but that doesn't seem to be the case when considering faces with holes in them. instead, parameters that correspond to the underlying face are returned.

4 REPLIES

Re: api function for getting closest point on a face?

I know this is an older thread, but this is similar to what I was faced with not long ago.  I ended up using the MinimumDistance method in part document.  The output of the method gives you the two closest points on the two faces/edges/point that you specify (in addition to the minimum distance).  I was actually trying find the closest face to a given point.  it worked well for me.

Re: api function for getting closest point on a face?

Hi, this is exactly what I need but I can't seem to call the method correctly. I need to find a face closest to a specified point but when I try to pass a Point3D and a Face as the arguments I get "System.Runtime.InteropServices.COMException: 'Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))' ".

Could you please give a short example how to init a point (for example at [0, 0, 0]) and check a minimum distance from a face?

Re: api function for getting closest point on a face?

Kammie,

 

I don't know if this will help or not.  I was importing points from excel and in ST8 the only was was to create a coordinate system at the point.  You then had to get the "edge" or axis, then the vertex.  the vertex could be used in the MinimumDistance method.

 

Set objCoordSys = objCoordSysSet.Add(XOffset, YOffset, ZOffset, 0, 0, 0, 0)
'get edge then vertex of axis system

Set ax = objCoordSys.Axis(SolidEdgePart.CoordinateSystemFeatureConstants.seCoordSysXAxis)
Set vx = ax.StartVertex

Set objRef1 = vx
Set objRef2 = objFaces.Item(iLoopCount)

 

Call objPartDoc.MinimumDistance(objRef1, objRef2, Distance, dblPoint1, dblPoint2)

 

You can try this as a workaround just to see if it gets you past the error.

 

Scott

 

Re: api function for getting closest point on a face?

Awesome! Thank you, that was exactly what I needed Smiley Happy 

I was hoping to be able to create a Vertex directly without any overhead but this is very close and works as expected. Thanks again!