Call C++ Methods from GH Component

Hi,

I was wondering what is the best and fastest method to call/invoke C++ Methods from a custom made (C# based) GH component.

Is the GH “C# script” component the starting point? If no what is? And if yes, what is the optimal way to call a C++ dll from it?

Thanks!

Your only option to call C++ methods from .NET (C#) is to use P/Invoke.

This is the method I use for my Cycles renderer GH component.

/Nathan

Hi,

thanks for the tip!

However since I already knew that calling a DLL from .NET is usually done over Invoke, my question was related more to “how”… Is GH “C# script” the best way, and if yes how would an example code look like…

Greetings!

I haven’t used GH C# Script, but my understanding is that the scripting bit is better suited for fast prototyping.

I’d go for writing just a C# plug-in that implements your components. This gives you probably more control over potential GUI stuff as well. The Grasshopper SDK explains creating custom C#/VB.NET components quite well.

/Nathan