Point cloud point selection



I need a fast way to select points of a pointcloud. In Rhino this can be done with the tool pointcloud -> remove points. Does anyone know how to do this in python / rhino common?

Thanks in advance!


You can use PointCloud.PointAt if you want to get the coordinate of a point in a specific index of a point cloud:

import rhinoscriptsyntax as rs
pointCloud = rs.GetObject("Select point cloud", rs.filter.pointcloud)
pointCloud = rs.coercegeometry(pointCloud)

powerpp.py (182 Bytes)


Thanks Mahdiyar,
but what I am looking for is a fast way to get a point cloud subselection.
I need to know the indices or coordinates of the selected points (within selection rectangle)

(Graham) #4

Maybe using one of the RTree methods - there seem to be some dedicated specifically to point clouds. If I understand correctly they should be very fast :rocket:



Also thank you Graham. Yes - RTree is a fast way to work on a pointcloud. The disadvantage is, that you first have to initialize all points to an rtree.
But I need a very quick way of selecting points from a pointcloud with a selection window. This can be done in rhino by using the tool for removing points from a pointcloud. I assume there is some openGL stuff behind this. Hopefully this is wrapped in some way in rhino common…



Are you looking for GetObjects with filter = 2?



Thanks rgr, but this would select the entire pointcloud. I need a sub-selection as shown in the picture. This picture was taken while using the rhino tool for removing points of a pointcloud (yellow, selected points will be removed from the pointcloud and inserted as points in rhino after confirming the command)


@powerpp, i figured, there could be multiple pointclouds (and points) in the window selection, so getting the selected pointcloud point indices required some stretching…

import Rhino
from collections import defaultdict

def DoSomething():
    # prompt for pointcloud points
    go = Rhino.Input.Custom.GetObject()
    go.SetCommandPrompt("Select pointcloud points")
    go.GeometryFilter = Rhino.DocObjects.ObjectType.Point
    go.GetMultiple(1, 0)
    if go.CommandResult() != Rhino.Commands.Result.Success: return 
    if not go.Objects(): return 
    # dictionary: (key = cloud object guid, value = selected cloud pt indices)
    my_dict = defaultdict(lambda: [])
    for obj_ref in go.Objects():
        if isinstance(obj_ref.Object(), Rhino.DocObjects.PointCloudObject):
    for cloud_id, indices in my_dict.iteritems():
        print "CloudId: {} >>> {} points selected".format(cloud_id, len(indices))



1 Like

Perfekt! Thanks a lot for this Clement.
It is exactly what i was looking for (even more).
Have a nice week!