Any suggestions for beginner coding in C# with Grasshopper-Rhino?

For a seasoned beginner such as myself who has done a few crash courses in C# and done quite a bit in Unity3d but am still unsure of my abilities to write code from scratch, especially with the RhinoCommon SDK, how might you suggest getting started with C# scripting with Grasshopper-Rhino? I am using the Mac Rhino Grasshopper WIP, which has a very limited C# IDE with no folding nor IntelliSense following the dot operator; beggars can’t be choosers though!

I went through this tutorial series and it makes sense; I’d like to start playing around with my own scripts and I suppose the best way to do that is to just muck around using the RhinoCommon SDK documentation?

I imagine a good place to start is to just script basic workflows that I would otherwise do using the existing Rhino UI –
e.g. make a circle and then extrude it. Just a thought, but I appreciate whatever guidance you might have.

@jarombra Glad to hear you are on your way to developing with c# and RhinoCommon!

Yeah, this is a pain point that will be resolved eventually. @dan and @Alain might have some ideas of when a more useful c# component might be available in Grasshopper for mac.

In the mean time, you can check out our developer resources, which explain how to get started creating your own plugins with Visual Studio for Mac.

You could perhaps create a simple plugin with the rhino add-in for visual studio for mac (one of the steps in the developer docs for mac), and try out code there with all the nice features like intellisense, etc.

1 Like

VS17 and the templates for GH. Its the way to go.

1 Like

VS17 is the way to go for sure and what I intend to do, but any reason why you’d suggest making plugins (new components) for GH rather than just a .rhp for Rhino proper? I like the idea of adding a new command to Rhino =)

Thanks.

Hi @jarombra,

There is no reason why you shouldn’t start by writing a plug-in. Adding new commands can be quick, easy, and a great way to learn more about programming in Rhino.

There may become a point where you want to access some of your fanciness in Grasshopper. The skills you acquire writing a plug-in will be beneficial if or when you choose to write an Grasshopper add-on.

– Dale

1 Like

Thanks @dale I appreciate the enthusiasm and support! For now I intend on keeping it within Rhino proper and perhaps moving into GH later as you suggested. Looking forward to it! I’m working through the “my first plugin” guide as we speak. Rhino has fantastic developer documentation.

2 Likes

We made workshop for that.

In my website you can find tutorials and example files:

2 Likes

@jody, if we haven’t blogged about the C# for Grasshopper class (see link above), can we?

– Dale

@dale & @fraguada Alright, well, following the Your First Plugin (Mac) tutorial successfully, I have to say this is quite fun. But here’s a dumb question coming from someone who has only ever used VS in a Unity C# script writing context: how do I now build/export My First Plugin (Mac) as a *.rhp that can be installed into the Rhino Plugin Manager? Not that I want to do this, but presuming I will someday make actually useful plugins of my own, it would be good to know! =)

Also, a bit of a higher-level question: can one develop plugins for Rhino Mac in the method laid out in the tutorial without worrying about cross-platform compatibility, as the “clone project files method” will always be doable later? Goes without saying, I have little experience with solution architecture and am hoping that I can simply develop plugins for Mac and if need be clone them to Windows later without too much forethought.

There’s a guide for that! https://developer.rhino3d.com/guides/rhinocommon/plugin-installers-mac/

Also glad you are thinking about that! In theory, anything in your plugin that uses RhinoCommon should be cross platform. There are a few things that have not made it over to Mac, but that list shrinks each day. I’ve only run into it in cases that deal with mesh modifiers like Shut Lining, Edge Softening, etc. The biggest issue will be UI. If you only use command line options, you will have no issues. If you have any sort of graphical ui, this is where you need to do some planning. For Rhino 6 this should be easier due to the use of Eto, a cross platform .net UI library that targets the native UI components of the system.

2 Likes

Ah of course, hiding in plain sight! Thanks @fraguada. And yeah, for the foreseable future I plan on keeping my plugins command line only, so it sounds like I’m good to go with this workflow. Thanks again for your help!

2 Likes

I have many instances where the code to make an adequate user interface that is more functional than pure command line is simply too complicated, in these few cases i write to a grasshopper component and slap it into the properties panel for grasshopper in rhino. thsi accounts for about 30% of my tools for my team, usually the designers who need a more “organic” way to draw, rather than a pure technical numbers method…