Clone wiki

tarsier / Interoperability

As GH_PointCloud directly wraps Rhino.Geometry.PointCloud hence the two can be cast directly. This means we also directly use Rhino's native display pipeline, allowing very large point clouds.


  private void RunScript(System.Object cloudObj, ref object cloudOut)
    // Since Rhino.Geometry.PointCloud is already in the SDK, we don't need any dependencies
    // And our object can be cast directly
    PointCloud cloud = (PointCloud) cloudObj;

    Random rng = new Random(2);
    // Iterate through the Rhino.Geometry.PointCloudItem list
    foreach (PointCloudItem item in cloud) {
      // Do something with it
      item.Color = System.Drawing.Color.FromArgb(rng.Next(0, 255), rng.Next(0, 255), rng.Next(0, 255));

    // Since a point cloud is IEnumerable of PointCloudItem, we need to wrap it as an object
    cloudOut = new GH_ObjectWrapper(cloud);
    // We will then be able to plug it into the point cloud parameter to have a GH_PointCloud



from Rhino.Geometry import PointCloud, PointCloudItem
from System.Drawing import Color
from Grasshopper.Kernel.Types import GH_ObjectWrapper
import random as rd

# cloud is the component input, a GH_PointCloud or Rhino.Geometry.PointCloud
for item in cloud:
    item.Color = Color.FromArgb(rd.randint(0, 255), rd.randint(0, 255), rd.randint(0, 255));
cloudOut = GH_ObjectWrapper(cloud);

GH_PointCloud components will also parse GH_GeometricGoo<PointCloud>, meaning that other point cloud implementations can be directly parsed, ie. Volvox. However if those libraries do not implement the same (or at least a parsing of Rhino.Geometry.PointCloud), deconstruction and reconstruction is required for the reverse. Conversion_01_Volvox_Basics.png