Click or drag to resize
PlaneDistanceTo Method
Returns the signed distance from testPoint to its projection onto this plane. If the point is below the plane, a negative distance is returned.

Namespace: Rhino.Geometry
Assembly: RhinoCommon (in RhinoCommon.dll) Version: 5.1.50000.0 (5.0.20693.0)
public double DistanceTo(
	Point3d testPoint


Type: Rhino.GeometryPoint3d
Point to test.

Return Value

Type: Double
Signed distance from this plane to testPoint.
using System.Linq;
using Rhino;
using Rhino.DocObjects;
using Rhino.Geometry;
using Rhino.Commands;
using Rhino.Input;

namespace examples_cs
  public class IsPlanarSurfaceInPlaneCommand : Command
    public override string EnglishName { get { return "csIsPlanarSurfaceInPlane"; } }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
      ObjRef obj_ref;
      var rc = RhinoGet.GetOneObject("select surface", true, ObjectType.Surface, out obj_ref);
      if (rc != Result.Success)
        return rc;
      var surface = obj_ref.Surface();

      Point3d[] corners;
      rc = RhinoGet.GetRectangle(out corners);
      if (rc != Result.Success)
        return rc;

      var plane = new Plane(corners[0], corners[1], corners[2]);

      var is_or_isnt = "";
      if (IsSurfaceInPlane(surface, plane, doc.ModelAbsoluteTolerance))
        is_or_isnt = " not ";

      RhinoApp.WriteLine("Surface is{0} in plane.", is_or_isnt);
      return Result.Success;

    private bool IsSurfaceInPlane(Surface surface, Plane plane, double tolerance)
      if (!surface.IsPlanar(tolerance))
        return false;

      var bbox = surface.GetBoundingBox(true);
      return bbox.GetCorners().All(
        corner => System.Math.Abs(plane.DistanceTo(corner)) <= tolerance);
import Rhino
from Rhino.Geometry import *
import rhinoscriptsyntax as rs
from scriptcontext import doc
import math

def RunCommand():
  surface_id = rs.GetSurfaceObject()[0]
  if surface_id == None:
  surface = rs.coercesurface(surface_id)

  corners = rs.GetRectangle()
  if corners == None:

  plane = Plane(corners[0], corners[1], corners[2])

  is_or_isnt = "" if IsSurfaceInPlane(surface, plane, doc.ModelAbsoluteTolerance) else " not "
  print "Surface is{0} in plane.".format(is_or_isnt)

def IsSurfaceInPlane(surface, plane, tolerance):
  if not surface.IsPlanar(tolerance):
    return False

  bbox = surface.GetBoundingBox(True)
  rc = True
  for corner in bbox.GetCorners():
      if math.fabs(plane.DistanceTo(corner)) > tolerance:
          rc = False

  return rc

if __name__ == "__main__":
See Also