Calling grasshopper components in C# for grasshopper

Hi All,
Lets say I want to call “mass addition” or “curve x line intersect” component within a script inside C# for Grasshopper. How do I go about this? Any help dark side dwellers?.

1 Like

I’am kind new could you load in a simple .gh file with a basic script calling in any simple component. I could be glad to take it from there.
Cheers!

This example will invoke Mass Addition.
Please, still read the whole tutorial.

invoke.mass.addition.gh (3.0 KB)

2 Likes

Is there any difference in speed between doing things like that vs writing a regular simple C# addition for loop to do what mass addition does, or just using .Sum();? Just curious in general if any speed is compromised via node in code for these simpler routines.

NodeInCode will call the component. It will behave like it, and will take essentially the same time.
Other methods might be faster, but this re-uses exactly the same logic as Grasshopper.

Dear Giulio,
I Appreciate the prompt response. Thanks this helped me alot in understanding the core concepts.

Cheers,
Mr A.

I got a problem. The result[0] is type ‘object’ which cannot be converted or cast in the same C# script. How can I solve this?invoke.mass.addition.gh (4.0 KB)