Rectangle Selection C# Development RhinoGet.Get2dRectangle()

i am trying to create a selection tool to select vertices of a mesh in the first attempt I have used Result selectionResult = RhinoGet.GetRectangle(GetBoxMode.Corner, ptt, null, out cornerPoints); but it is not working well as the plane where the rectangle is build is not always perfect. i would like to use RhinoGet.Get2dRectangle(true, out Rectangle rectangle, out Rhino.Display.RhinoView rectView); but the result for rectangle is a selection rectangle in window coordinates. my question is how do i move forward with this 2d rectangle to select a set of mesh points.
here is some code below

//click to get point on mesh
                    Point3d ptt = gp.Point();
                    Plane constPlane = new Plane(RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.CameraLocation, RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.CameraDirection);

                    Plane orientPlane = OrientViewPlane(constPlane, RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.CameraDirection, RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.CameraY);

                    Point3d[] cornerPoints;

                    //Result resultCplane = MoveCPlane(doc, orientPlane);
                    //set construction plane
                    Result resultCplane = MoveCPlane(doc, constPlane);

                    if (resultCplane == Result.Failure)
                        return Result.Failure;
                    Result selectionResult = RhinoGet.GetRectangle(GetBoxMode.Corner, ptt, null, out cornerPoints);

                    //Rectangle rectangle;
                    //Rhino.Display.RhinoView rectView;
                    //Try to create rectangle using screen box
                    //RhinoGet.Get2dRectangle(true, out rectangle, out rectView);

                    if (selectionResult == Result.Cancel)
                        return Result.Cancel;

                    List<Mesh> meshL = new List<Mesh>();
                    int[] indices;

                    Point3d[] prjPoints = Intersection.ProjectPointsToMeshesEx(meshL, cornerPoints, RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.CameraDirection, 0, out indices);
                    List<Point3d> plnPts = new List<Point3d>();

                    if (polyline.Count == 0 || ptt.DistanceToSquared(polyline.Last) > 0.01 && cornerPoints.Count() == 4)


                    //reset world plane 
                    MoveCPlane(doc, Plane.WorldXY);

Hi @Arjun_Sharma1,

A different approach:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
  var go = new GetObject { GeometryFilter = ObjectType.MeshVertex };
  go.SetCommandPrompt("Select mesh vertices");
  go.GetMultiple(1, 0);
  if (go.CommandResult() != Result.Success)
    return go.CommandResult();

  foreach (var objref in go.Objects())
    var rhobj = objref.Object();
    var mesh = objref.Mesh();
    if (null == rhobj || null == mesh)
      return Result.Failure;

    var ci = objref.GeometryComponentIndex;
    if (ci.ComponentIndexType != Rhino.Geometry.ComponentIndexType.MeshTopologyVertex)
      return Result.Failure;

    var vertices = mesh.TopologyVertices.MeshVertexIndices(ci.Index);
    RhinoApp.WriteLine("Topological Vertex {0}: Vertices: {1}, Location: {2}", 
      ci.Index, vertices.Length, mesh.Vertices[vertices[0]].ToString());


  return Result.Success;

– Dale

Hello Dale Fugier, thanks for the reply, the code by itself works. but what i want is to have a rectangle selection and select multiple mesh points at the same time this code is prompting me to select single points , even after using GetMultiple().
Please Help
Thanks in Advance

Hi @Arjun_Sharma1,

Run my sample code. And when prompted to “Select mesh vertices”, drag a selection rectangle around the vertices you want to select.

Does this help?

– Dale

Hello Dale
Rectangle selection works well when the rectangle begins on top of the mesh face. if it begins on top of a mesh vertex then the script only selects that mesh vertex and doesent make the selection rectangle. as the mesh i am using is very dense majority of the time it selects a single mesh point unless I zoom in to select which is not ideal.


Hello @dale
is there some way I can change this code to prevent it from selecting single mesh vertex points?
Thanks for all the support