1

I am using this code to have the user select specific points from a loaded point cloud. The point is to allow them to manually prune the pointcloud and later create an automatic outlier detection to prune these points. However, I can't find anywhere how these points could be deleted?

       {
           ObjRef[] obj_refs;
           var rc = Rhino.Input.RhinoGet.GetMultipleObjects("Select point", false, ObjectType.Point, out obj_refs);
           if (rc != Result.Success)
               return rc;
           foreach (var o_ref in obj_refs)
           {
              var point = o_ref.Point();
               RhinoApp.WriteLine("Point: x:{0}, y:{1}, z:{2}",
                 point.Location.X,
                 point.Location.Y,
                 point.Location.Z);

           }
           doc.Objects.UnselectAll();

           doc.Views.Redraw();
           return Result.Success;
       }```
Niek
  • 11
  • 1
  • i am curious about this too. but better ask this question in the Mcneel Forum. https://discourse.mcneel.com/ – Wiley Ng Nov 26 '21 at 12:23

2 Answers2

0

In the ForEach loop, you can add an IF statement to select only those points you want. Something like this:

foreach (var o_ref in obj_refs)
       {
         if (o_ref.property == "only the one you want")
          {
           var point = o_ref.Point();
           RhinoApp.WriteLine("Point: x:{0}, y:{1}, z:{2}",
             point.Location.X,
             point.Location.Y,
             point.Location.Z);
          }
       }
Fred Smith
  • 2,047
  • 3
  • 25
  • 36
  • Selecting the points is not the problem though. I just don't see a way to remove the selected points from the pointcloud? – Niek Nov 05 '21 at 13:50
0

You can first try to grab the index of the specific point your are searching for in the PointCloud object. Next, by using this function

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_PointCloud_RemoveAt.htm

so I think the main line will be

obj_refs.RemoveAt(index);