Click or drag to resize

ObjectTableSelect Method (IEnumerableGuid)

Selects a collection of objects.

Namespace:  Rhino.DocObjects.Tables
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 5.0
Syntax
public int Select(
	IEnumerable<Guid> objectIds
)

Parameters

objectIds
Type: System.Collections.GenericIEnumerableGuid
Ids of objects to select.

Return Value

Type: Int32
Number of objects successfully selected.
Examples
using Rhino;
using Rhino.Geometry;
using Rhino.Geometry.Intersect;
using Rhino.Input.Custom;
using Rhino.DocObjects;
using Rhino.Commands;

namespace examples_cs
{
  public class CurveSurfaceIntersectCommand : Command
  {
    public override string EnglishName { get { return "csCurveSurfaceIntersect"; } }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var gs = new GetObject();
      gs.SetCommandPrompt("select brep");
      gs.GeometryFilter = ObjectType.Brep;
      gs.DisablePreSelect();
      gs.SubObjectSelect = false;
      gs.Get();
      if (gs.CommandResult() != Result.Success)
        return gs.CommandResult();
      var brep = gs.Object(0).Brep();

      var gc = new GetObject();
      gc.SetCommandPrompt("select curve");
      gc.GeometryFilter = ObjectType.Curve;
      gc.DisablePreSelect();
      gc.SubObjectSelect = false;
      gc.Get();
      if (gc.CommandResult() != Result.Success)
        return gc.CommandResult();
      var curve = gc.Object(0).Curve();

      if (brep == null || curve == null)
        return Result.Failure;

      var tolerance = doc.ModelAbsoluteTolerance;

      Point3d[] intersection_points;
      Curve[] overlap_curves;
      if (!Intersection.CurveBrep(curve, brep, tolerance, out overlap_curves, out intersection_points))
      {
        RhinoApp.WriteLine("curve brep intersection failed");
        return Result.Nothing;
      }

      foreach (var overlap_curve in overlap_curves)
        doc.Objects.AddCurve(overlap_curve);
      foreach (var intersection_point in intersection_points)
        doc.Objects.AddPoint(intersection_point);

      RhinoApp.WriteLine("{0} overlap curves, and {1} intersection points", overlap_curves.Length, intersection_points.Length);
      doc.Views.Redraw();

      return Result.Success;
    }
  }
}
Python
import rhinoscriptsyntax as rs
from scriptcontext import *
import Rhino
import System.Collections.Generic as scg
import System as s

def RunCommand():
  srfid = rs.GetObject("select surface", rs.filter.surface | rs.filter.polysurface)
  if not srfid: return

  crvid = rs.GetObject("select curve", rs.filter.curve)
  if not crvid: return

  result = rs.CurveBrepIntersect(crvid, srfid)
  if result == None:
    print "no intersection"
    return

  curves, points = result
  for curve in curves:
    doc.Objects.AddCurve(rs.coercecurve(curve))
  for point in points:
    rs.AddPoint(point)

  doc.Views.Redraw()

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