Migrating RVB to RhinoCommon


#1

Hello, I am attempting to write a pure common rhino add-in from an old rhinoscript (rvb file). There are a couple methods that I am unsure about and cannot seem to find.

I am trying to test points and see if they are on a surface similar to something like:

For Each point In myArray
	If Rhino.IsPointOnSurface(Rhino.FirstObject, point) Then
            'do something
            End If
Next point

I cannot seem to find the equivalent in the SDK, I would have thought it would be under the point class, but I cannot seem to find it anywhere. What method should I be looking to use in Rhino Common?


#2

The Python/RhinoCommon routine called by IsPointOnSurface is the following:

def IsPointOnSurface(object_id, point):
    """Verifies that a point lies on a surface
    Parameters:
      object_id: the object's identifier
      point: list of three numbers or Point3d. The test, or sampling point
    Returns:
      True if successful, otherwise False
    """
    surf = rs.coercesurface(object_id, True)
    point = rs.coerce3dpoint(point, True)
    rc, u, v = surf.ClosestPoint(point)
    if rc:
        srf_pt = surf.PointAt(u,v)
        if srf_pt.DistanceTo(point)>scriptcontext.doc.ModelAbsoluteTolerance:
            rc = False
        else:
            rc = surf.IsPointOnFace(u,v) != Rhino.Geometry.PointFaceRelation.Exterior
    return rc

So, it’s seeing if the distance from the chosen point to the surface closest point is less than file tolerance, then it’s also checking to see if that point lies within the trimmed surface boundary (because the first method operates over the entire untrimmed face)

The relevant parts are in Rhino.Geometry.Brep and .BrepFace classes

HTH, --Mitch