From OpenNurbs to RhinoCommon

I am sure this will be a fairly uncommon question, so here we go:

I have a C++ DLL that uses OpenNURBS to read and write .3dm files, as well as generate ON_Brep, ON_Curve, and ON_Surface objects. We are currently extending our app to C# to use Rhino.compute for automation.

Is there any way I can move my C++ classes into the equivalent C# classes to be sent to Rhino.Compute? The only solution that comes to mind is saving the data as a .3dm file and reading it back via RhinoCommon or sending directly the file to be opened by the rhino.compute server

— Gerry

You can use RhinoCommon’s Interop class for moving your C++ classes into RhinoCommon equivalents

https://developer.rhino3d.com/api/rhinocommon/rhino.runtime.interop

You will need to create exported C functions from your C++ DLL that your C# code can call.

An example of this can be found here

Thanks Steve

But I am afraid I made a big mistake in my request. I would like to transfer the objects resident in c++ to rhinocommon

For example I have a ON_BRep in c++ memory how can I get the object in The c# to use within my c# classes.

I think that only a serialization/de serialization can work

Gerry

RhinoCompute calls C# code which can be your C# code. Your C# code would call your C++ code to get C++ pointers to OpenNURBS data types and then use the Interop class to wrap those C++ pointers into C# RhinoCommon classes.