https://github.com/jeremytammik/RevitSdkSamples/tree/master/SDK/Samples/PointCloudEngine/CS
Above link really helped us understand how PointCloud works, and we were able to create our own custom engine.
We are focusing on PredefinedPointCloud class, because we want to provide non-file-based input.
Step-1: Create your engine (use the code provided in the above link,)
Step-2: Initialize your engine, and register it.
IPointCloudEngine engine = new BasicPointCloudEngine(PointCloudEngineType.Predefined);
PointCloudEngineRegistry.RegisterPointCloudEngine("apipc", engine, false);
We do this only once, so we have put above code in start-up part of the addin.
Step-3: Provide input to the engine.
Whenever we want to provide the input of XYZ coordinates, we create a list of all the coordinates we want to highlight, and make that list available throughout our package.
Now, there is a method called GeneratePoints in PointCloudCellStorage, which adds all the individual points to a buffer called m_pointsBuffer.
We can't call that method directly, because it is being called automatically by Revit when we use PointCloudType.Create().
So, we changed the GeneratePoints in method our engine and made it iterate through our list of coordinates, and add those points to the buffer m_pointsBuffer.
Step-4: Display your points.
PointCloudType type = PointCloudType.Create(m_doc, "test", "");
PointCloudInstance instance = PointCloudInstance.Create(m_doc, type.Id, Transform.Identity);
So, here when we use PointCLoudType.Create(), it will eventually automatically call the method GeneratePoints and highlight our provided list of points.
We also used doc.delete(instance.id), so every time we create new instance, it'll delete the old PointCloudInstance.
For speed, it can highlight about 100,000 points per second. So, that's impressive.
A major drawback is that the highlighted part is very small, so you would want to create a group of points together, so the cluster can be easily visible.
I hope above explanation is understandable.