Point cloud point selection

@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):
            my_dict[obj_ref.Object().Id].append(obj_ref.GeometryComponentIndex.Index)
    
    for cloud_id, indices in my_dict.iteritems():
        print "CloudId: {} >>> {} points selected".format(cloud_id, len(indices))

DoSomething()

_
c.

2 Likes