Point clouds as Grasshopper contextual inputs

Hello, apologies if this has been discussed before but I couldn’t find a straight answer anywhere and Grasshopper is driving me mad.

I want to have Rhino point cloud objects (not from file, but generated from Veesus selection) as input to a “Get Geometry” element in a Grasshopper script so that I can run it using GrasshopperPlayer, select one or multiple point clouds, and have grasshopper perform some action on each point cloud. At the moment when I use “Get Geometry” and try to select a point cloud, it just selects individual points.

Can a point cloud in the model space ever be an input to a Grasshopper script and if so how?
And, are there any plans to add a “Get Point Cloud” contextual input for Grasshopper?

What is this?

Other than that dealing with a PC is rather easy via code. See what this C# does (3 workModes available - for this case (captured below) works by importing to R a PC collection):


And here’s the code that does the main thing:

So if you are familiar with C#, notify.

1 Like

Hi,

There is no direct method to select or even reference PointCloud geometry directly into Grasshopper.
You can check out Cockroach Plugin which has a component to select a pointcloud like how you would reference any other geometry.

If you would like to dig a bit deeper, here is a pythonic version of importing point cloud from Rhino into GH.

image

""" Imports all pointclouds in the current Rhino Document.

    Input:
        select <bool> : ItemAccess
    Output:
        clouds <list[Rhino.Geometry.PointCloud]>
"""
__author__ = 'Kaushik LS'

import Rhino

clouds = []
if select:
    for obj in Rhino.RhinoDoc.ActiveDoc.Objects:
        if isinstance(obj, Rhino.DocObjects.PointCloudObject):
            clouds.append(obj.Geometry)

If you’re looking to select a specific point cloud, use this then

""" Implementation of Get PointCloud(s). Imports selected PointCloud.
    
    Input:
        select <bool> : ItemAccess
    Output:
        clouds <list[Rhino.Geometry.PointCloud]>
"""
__author__ = 'Kaushik LS'

import Rhino

clouds = []
if select:
    result, ref_obj = Rhino.Input.RhinoGet.GetMultipleObjects('Select PointCloud(s)', False, Rhino.DocObjects.ObjectType.PointSet)
    if isinstance(result, Rhino.Commands.Result.Success):
        clouds = [obj.Geometry() for obj in ref_obj]

Edit:

Check attached file to use it in Grasshopper Player.
FIle: select_pointclouds.gh (3.9 KB)

image


HTH

~ ~ ~ ~ ~ ~ ~ ~
Kaushik LS
Chennai, IN

1 Like

Great answer, thank you for this.