Set and get parameter for own CustomRenderMeshProvider

Hi,

For a project, I need to write my own CustomRenderMeshProvider for which also a properties page is added. The only problem is, that the CustomRenderMeshProvider2 class is only little documented and I found only one example where one tried to write his own render mesh provider:

https://discourse.mcneel.com/t/how-to-keep-texture-mapping-result/60303

The problem is, that this is already a very old post and that it’s written in C++, but I have to develop in C#.

I already have created a class, which inherits from CustomRenderMeshProvider and overloads the BuildCustomMeshes and WillBuildCustomMeshes methods, as well as the properties page UI, but now I’m stuck at passing the parameters to the render mesh provider. In this post it is described, that I need to call the SetCustomRenderMeshParameter and GetCustomRenderMeshParameter methods of the Rhino objects I want to add parameters to get them in the BuildCustomMeshes method. For those methods, the provider ID needs to be passed as the first argument, but where do I get it? I already tried to use the GUID of the provider class type (via typeof(MyRenderMeshProvider).GUID), but it didn’t work. I set one value and immediately tried to read it again, but it always returns the default value.

My current solution is to add the parameters as custom user data to the Rhino objects such that I’m able to save the state when closing the Rhino project.

Is there any more description of how to do it?

Thanks for your help already,
Pascal

The new class is essentially the same as the old one, with the exception of taking a document during construction.

See this C# sample code for a custom render mesh provider: https://github.com/mcneel/rhino-developer-samples/tree/6/rhinocommon/cs/SampleCsRdk