Click or drag to resize

IntersectionProjectPointsToMeshesEx Method

Projects points onto meshes.

Namespace:  Rhino.Geometry.Intersect
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 5.10
Syntax
public static Point3d[] ProjectPointsToMeshesEx(
	IEnumerable<Mesh> meshes,
	IEnumerable<Point3d> points,
	Vector3d direction,
	double tolerance,
	out int[] indices
)

Parameters

meshes
Type: System.Collections.GenericIEnumerableMesh
the meshes to project on to.
points
Type: System.Collections.GenericIEnumerablePoint3d
the points to project.
direction
Type: Rhino.GeometryVector3d
the direction to project.
tolerance
Type: SystemDouble
Projection tolerances used for culling close points and for line-mesh intersection.
indices
Type: SystemInt32
Return points[i] is a projection of points[indices[i]]

Return Value

Type: Point3d
Array of projected points, or null in case of any error or invalid input.
Examples
using System.Collections.Generic;
using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
using Rhino.Geometry.Intersect;
using Rhino.Input;
using Rhino.DocObjects;

namespace examples_cs
{
  public class ProjectPointsToMeshesExCommand : Command
  {
    public override string EnglishName { get { return "csProjectPointsToMeshesEx"; } }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      ObjRef obj_ref;
      var rc = RhinoGet.GetOneObject("mesh", false, ObjectType.Mesh, out obj_ref);
      if (rc != Result.Success) return rc;
      var mesh = obj_ref.Mesh();

      ObjRef[] obj_ref_pts;
      rc = RhinoGet.GetMultipleObjects("points", false, ObjectType.Point, out obj_ref_pts);
      if (rc != Result.Success) return rc;
      var points = new List<Point3d>();
      foreach (var obj_ref_pt in obj_ref_pts)
      {
        var pt = obj_ref_pt.Point().Location;
        points.Add(pt);
      }

      int[] indices;
      var prj_points = Intersection.ProjectPointsToMeshesEx(new[] {mesh}, points, new Vector3d(0, 1, 0), 0, out indices);
      foreach (var prj_pt in prj_points) doc.Objects.AddPoint(prj_pt);
      doc.Views.Redraw();
      return Result.Success;
    }
  }
}
Python
from System.Collections.Generic import *
from Rhino import *
from Rhino.Commands import *
from Rhino.Geometry import *
from Rhino.Geometry.Intersect import *
from Rhino.Input import *
from Rhino.DocObjects import *
from scriptcontext import doc

def RunCommand():
  rc, obj_ref = RhinoGet.GetOneObject("mesh", False, ObjectType.Mesh)
  if rc != Result.Success: return rc
  mesh = obj_ref.Mesh()

  rc, obj_ref_pts = RhinoGet.GetMultipleObjects("points", False, ObjectType.Point)
  if rc != Result.Success: return rc
  points = []
  for obj_ref_pt in obj_ref_pts:
    pt = obj_ref_pt.Point().Location
    points.append(pt)

  prj_points, indices = Intersection.ProjectPointsToMeshesEx({mesh}, points, Vector3d(0, 1, 0), 0)
  for prj_pt in prj_points: 
    doc.Objects.AddPoint(prj_pt)
  doc.Views.Redraw()
  return Result.Success

if __name__ == "__main__":
  RunCommand()
See Also