Where is Grasshopper.Kernel.Special in grasshopper API?

Hi, guys.

lastely I`m trying to use python in Grasshopper, I found that Grasshopper.Kernel.Special is not documented in Grasshopper API

Where I can I find its info and all method that listed under this namespece instead? Is there any file like rhinocript document that save all related files in?

Try: print(dir(Grasshopper.Kernel.Special)).

Sometimes concrete versions of the generic types need to be declared in the C# way, not the Pythonic way (IronPython can still handle both). But beware, when you step outside the documented API, your code might break in future Rhino versions.

Thanks James, it does help a lot.

And I notice that Grasshopper.Kernel.Special only have part of input components, Where could I find the rest of components provided by grasshopper? like point, circle, vector or sweep 1/2…?

I would like to use ghpython to generate those components on grasshopper canvas, but now I can only create components in Grasshopper.Kernel.Special, like number slider or knob…

I did find a useful tool to Find the class for any Grasshopper component, but something got wrong when I tried to paste it into C# component and ran. I`m not so familiar with C#, is there anyway to fix it?

1 Like

To create Geometry objects on the Grasshopper canvas, you should just use set scriptcontext.doc to ghdoc, and follow

or take your pick from all the other rhinoscriptsyntax helper functions: Rhino - RhinoScriptSyntax

If you need to customise these more, then under the hood these functions use classes under the Rhino namespace instead :

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry

Any instance of one of those Rhino classes, outputted from a GhPython component, is visible on the GH canvas (highlighted in red).

Thanks, I`ve been through these pages.

I might not describe my mind so clear, what I want is to create the containers of geometry, like in the image, and then use python to assign geometry to these container components, but I didn`t find the class for creating these container components (or proxy components of geometry maybe, not so sure their official name).
Screenshot 2023-08-04 120718

Hi,

The guide to create those params in a custom component is here

However that is C#… Not certain it’s doable in Python directly in GH.

Ah sorry Fmyl, I misunderstood, and forgot what the Grasshoppper canvas means…

It is possible to add Grasshopper components in Python code, but I’ve never found any documentation about it. There’re old posts on the forum about it, and on the old grasshopper forum, e.g. discussing automatically building plug-ins. With GhPython components themselves at least, once you have an instance of the right class, some data about it might need to be filled in, and then it can be added as a reference to the intended grasshopper document.

Thanks for explanation James.
I`ve tried to import c# assembly files to python but didn’t work easily, maybe just because my understanding of python is not deep enough.
Now I’m wondering if I should move to c# or stick digging with python, not so sure which is easier way.

Thanks,Magicteddy, I’ll go through that page to seen if it’s able to convert to python

Use c# its much simpler for grasshopper but its first a hard experience if you come from python.

C# force you to program in oop style and its explicite …so you have to declare everything but grasshopper is c#.

Both ways are the same but learning c# is in my view better…maybe it will change with the new c python in rhino 8

1 Like

Wow, that is worth expecting, looking forward for the releasing

How to use C# Class Libraries (dll) in Python
I just found one post that is might be helpful, and will take some time to try out

:slightly_smiling_face: i see you dont want to leave the python road.

Just got C# book on my hand, but it will take a while to learn, i’m so new to coding. In the meantime, I think it is always good to know more ways to achieve the same goal.

This series is in my view very good for learning c# in Grasshopper.

Rhino is .net and .net is microsoft.
Also c# is microsoft.
Python in gh is ironpython (.net for python) and not c python thats the reason why lots of c python librarys dont work with gh …hops can be used to run c python code and interact with gh.

Rhino developer offer a lot of options to interact with other platforms…but mixing c# librarys with python is sometimes very frustrating…because of explicit and non explicit and .net and c.

I started with Python and had no idea of classes and objects and data type declaration.

But you will realise that on your path …python is really great for short tests but c# is in most cases much faster because of the declaration…not every line of code needs to be computed again and again like in python.

1 Like

many thanks for this video, looks like c# is a must-go for long term developing. l’m gonna watch it with my books.

One question I’m also considering is, does plug-in built by c# run on both Win and MAC platform like python did?

Good question…i dont know.

OK, then, I’ll figure it out