Extend PointCloud Class with Plugin C#


#1

I would like to add more members to the PointCloud (Item) Object.
Right now it supports Position, Color and Normal, but i need more.

I am not sure if this is possible, the forum search shows a few examples for meshes and grips.

First pitfall: the Rhino PointCloudItem Class has no public constructor - can i event extend it?

I managed to create a new PointCloud class with
public class MyPointCloud : PointCloud { ... } but as soon as i add it to the document it ends up as Rhino PointCloud again.

What would be the easiest way (if possible) to add a few members to the PointCloud? I don’t need to display or edit them, Rhino is just an intermediate step in the pipeline.

I haven’t tried User Data because i assume it will not work nicely with several million points.

Rhino 5 or 6…


(Nathan 'jesterKing' Letwory) #2

For Rhino 6 the easiest would be to create extension methods. Here some extension methods I created for some Rhino classes:

Essentially you just create a static class in a namespace and add static methods with a specific signature. For instance I added an extension method to MeshVertexColorList. The first parameter of such an extension is this DataTypeYouExtend paramname. Any arguments to the extension function follow after that.

To use such an extension method you only have to add using namespace.with.staticextensionmethodclass;

In the linked code you see have created several static classes as a grouping for the different extended datatypes. That isn’t strictly necessary, but useful to keep everything organised.

edit: you can then use such extension methods to interface with custom UserData. You probably could create such a data to the point cloud object instead of per point - index as necessary.

/Nathan