How to add a function of grasshopper into my plug-in?

I’m developing a plug-in using C#. How can I realize a function of grasshopper in my plug-in? When I searching on the internet, all of them are how to develop grasshopper functions, .gh files. However, I want to add a function to a .rhp plug-in. Is there any suggestion. Thanks very much.

A function like what? If you mean an oop function, just make a reference to Grasshopper.dll in your project, if you mean a component, you can’t, in gh their functions are not compiled separately from components and components are only solved within the gh solver (python allows it). You have to eat the crab with the shell, but this is the generic answer, there are some special methods (like voronoi) that they are isolated, then it depends on what function you want to use.

1 Like

Very appreciate for your answer. I want to create a cubic in the way of parameterization, and the size of the cubic can be changed by changing the inputs. Can this function be added to a .rhp plug-in?

Yes, but the cubic, if you mean a box, as any standard geometry, is in Rhinocommon.dll not in GH.

1 Like

Thank you, this indeed can build a box. But if I want to change the size of the box, I should build a new box and delete the old one. This is not a parameterize method. I want to make changes just on the box itself.

You can set the Plane, X, Y, and Z properties to edit the box size after it has been created:

1 Like

In addition to Anders’s reply, the reinstance is how GH works under the hood. When you change a parameter, a new object is created. In fact, even the instance is not retained when data is passed from one component to another, a copy is made. If the instance were preserved, subsequent component changes would change the object in previous components and would be chaos in linear algorithms.

1 Like

Thanks you, it helps a lot.

Thanks for your explanation, it is helpful.