I am relatavely busy between coding, Learning your SDK’s and writing some spec’s.
How do you manage the interaction between C++ and C#?
Is it possible to transfert an object from the C# part to the C++ side ?
If yes , how would you manage the transfert from a list (dynamic list) of object from C# side to the C++ side?
We write a bunch of helper functions and classes in C++ then use P/Invoke to have unmanaged and managed talk to each other.
It is quite a lot of work. You could look at i.e. CCSycles (https://github.com/mcneel/CCSycles) for how I do that for the Raytraced (https://github.com/mcneel/RhinoCycles) mode in Rhino WIP. Cycles is written in C++, the integration in Rhino with C# with RhinoCommon
Hi Markus,
You might also consider taking a look at the RhinoCommon source, which is on GitHub:
https://github.com/mcneel/rhinocommon
Essentially, C# can call “C” functions through a technique called Platform Invoke, or P/Invoke.
https://msdn.microsoft.com/en-us/library/aa446536.aspx
https://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx
If you look at the RhinoCommon project, you will see the C# classes used by those writing .NET plug-ins. These classes call 'C" functions in the rhinocommon_c DLL. This DLL in turn calls into the Rhino C++ SDK.
I’ve got a sample on my GitHub site that is a bit easier to digest then the RhinoCommon source:
https://github.com/dalefugier/Moose
– Dale
Another thing to keep in mind about P/Invoke is that it can be used to call unmanaged code written in any language from managed (.net) code written in any of the managed code languages. Of course, making sure the calling sequences line up is “an exercise for the user”.