I’d like to share a personal reflection that came up from my recent work with Grasshopper.
I’ve been using Grasshopper very intensively in different projects. Over time, I’ve always managed to build definitions that gave me the results I needed, often experimenting with new algorithms and approaches until I found an effective solution. In short: I feel at home in Grasshopper.
I also know there are other approaches – using scripting components with Python or C# – which can make things lighter, faster, and more compact. But I never really took the step, maybe because I felt too comfortable inside the visual environment and could always find “a way” with Grasshopper alone.
Recently though, I hit a problem I couldn’t solve. After months of attempts, I found on this forum a tiny C# component, just a couple of lines of code, that solved it immediately (it was about creating a mesh from a point cloud with constrained borders, using MeshFromTessellation). That was a wake-up call: what I couldn’t achieve with a long “spaghetti” definition, someone else solved in two lines of code.
This made me realize it’s probably time to expand my skills. I’m thinking of starting with Python, because it feels more accessible. I’m thinking of practicing directly in Grasshopper, using my existing knowledge as a foundation and creating exercises related to geometry and data trees.
I’d love to hear from others who went through this transition:
Did you start with Python or go directly to C#?
How did scripting change the way you use Grasshopper?
Any tips for someone who wants to learn coding specifically in the context of Grasshopper (not in the abstract)?
That’s a really useful perspective. Custom components running more typical (text) code in Grasshopper are incredibly powerful, but it can be tempting (often from igorance) to reimplement a feature that’s already provided to users by a native Grasshopper component.
I started with Python a couple of years ago with no prior coding experience other than toying a little with HTML and ActionScript as a teenager (and never went to C#).
It’s a solid choice and I still use it quite frequently. It’s also supported as a scripting language in many other applications like Blender, Maya, Revit, etc.
It’s great for beginners and with very little text you can do a lot, meaning prototyping something is fast and relatively straightforward. I do lots of stuff in C++ nowadays and the amount of text you write is hilarious in comparison.
I initially started scripting to do things that were either cumbersome or not possible with components in Grasshopper. Or I just wanted more control than just using somebody’s plug-in. I was very much into particles, agents and cellular automata at the time.
Small scripts usually let you accomplish stuff that you would need tons and tons of components for. Looping in Grasshopper is also very limited.
First learn the basic syntax of the language you decide to study and then immediately jump into a small project and start exploring and experimenting. That’s the best way to learn, for me at least.
Scripting in Grasshopper is also great because you immediately have a visual feedback, whereas traditionally you’d only have some text output in a terminal and implementing a graphics pipeline would be a huge drag.
I started with C#, unrelated to Rhino tho. It doesnt matter which one you pick, both are absolutely fine. I think Python is a bit more used in Rhino/GH than C#, judging by the forum posts.
I would start by picking up a good entry level book for the language of your choice.
I recently started a tutorial series on C# for the reasons you list above.
There are a few tutorials listed in the Rhino3D.education website: two (level 1 and level 2) Python courses and one C# course. I chose the C# course for no good reason and have been liking it so far. It has been motoring rather quickly through the programming fundamentals part. Eventually, at chapter 7 it starts dealing with the Rhino.Geometry namespace. While I did pay to have access to the videos, you could theoretically complete the entire course from the free PDF content alone. I don’t regret paying for the videos because I feel I can pace myself better with them.
There may be better (in-depth) tutorials on C# alone, but I think this course probably does a good job of teaching the language inside of the context I plan to use it. I wouldn’t know though. Most people here will probably tell you to go the Python route because it is such a common and versatile language. Most university students learn it nowadays.
I knew Python already and went with that. So many bugs in untyped Python are due to type mismatches - C# doesn’t suffer from this half as much being statically typed, and it is a really good language too.
I’m pleased you’re not considering VB - don’t touch it with a barge pole. When it comes to choosing between Python or C#, I would just say, try to think ahead about how you’ll deploy your app, how users will install it, and how they will update it. It can be both surprisingly easy, and surprisingly complicated, following the templates for C# projects.
On the other hand for me, Python, its source just being text strings, I felt had a real super power in Grasshopper when it came to Dev Ops. Python code can be used to manipulate other Python code (even itself in some situations) with incredible ease. I don’t know how I would’ve achieved hot reloads, or a user/self updatable plug-in in Grasshopper without Python. But I did have to fix tonnes of bugs too, and this approach has not caught on
Did you start with Python or go directly to C#?
C# first, but it was the better choice years ago, nowadays Python might be the better starting point. It depends, because both languages might use deprecated version/syntax in Rhino. This makes it a bit awkward if you follow generalised tutorials
How did scripting change the way you use Grasshopper?
I started early and it made GH definition very small, flexible and maintainable.
Scripting lets you think out of the box and allows you to solve problems with a much higher freedom and efficiency. You extend the abilities of GH. For the majority of problems only your own skill is the limit.
Any tips for someone who wants to learn coding specifically in the context of Grasshopper (not in the abstract)?
The key aspect of becoming good in coding is to well-understand the basic concepts. Don’t learn to use Rhino functionality, learn how to read API’s in general. Therefore you need a solid understanding of the language! (the first takes longer to learn, for any other language, the learning curve gets lower and lower). As a bonus task, look at some basics about object-orientated programming and common patterns.
Writing plugins is biased, but this means you can also focus on the “business” logic. This might lead to a overestimation of your skill, but it keeps the fun-factor high. Try to solve simple problems, but finish them. Motivation is key. Try to avoid using plugins for “simple” tasks, instead reinvent the simple wheels.
Once you are confident in calling Rhino functionality, learn the key concepts on how to call 3rd party libraries, how to perform communication to other services/apps (WebRequests, COM-Interface, Sockets etc.) and also learn more about algorithms, the math etc. Very often the show-stopper is the lack of understanding. Scripting 4 lines of Rhinocommon code is trivial. You don’t need to understand anything. Technically its not your achievement.
And last but not least, learn more about debugging, error handling and logging.