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;
polyline.Clear();
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>();
meshL.Add(AirteamPlugin.airteam_mesh.MeshGeometry);
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)
{
plnPts.Add(prjPoints[0]);
plnPts.Add(prjPoints[1]);
plnPts.Add(prjPoints[2]);
plnPts.Add(prjPoints[3]);
plnPts.Add(prjPoints[0]);
polyline.AddRange(plnPts);
}
UpdateAllPolylines();
//reset world plane
MoveCPlane(doc, Plane.WorldXY);