Hey guys,
I want to develop my first Grasshopper Plugin for Mac. I have never done this before. I am currently watching the large course from Long Nugyen, however, they use Mac and are using a Rhino Grasshopper Plugin Template for Visual Studio. Is there a similar template available for Mac? Or any sources how to start from scratch?
I found the tutorial you linked decent enough for a quick start, but missing some fairly critical elements like making my components have icons. For icons, I found this forum post very helpful.
I think it would be super helpful if the tutorial above included adding an icon. It took a fair leap to get there, when I think adding an icon to a training template project should be a 3-minute task.
I got there by
adding an IconLoader.cs file, which provides a lil code that gets load the icon file just given the filename. Got this directly from the forum post I linked.
adding my icon files inside Properties/Resources/
Adding an ItemGroup to my project.csproj file with a wildcard so I don’t have to manually list all the png icon files. I can just drop them in the folder and I’m good to go.
For each component, using a call to the IconLoader.GetIcon
It took me quite an effort to get all these things set up, and it would be great for the tutorial to include this (or for the template to just include these things with a sample icon file that a component uses). I accomplished these steps mainly using the forum post I linked above. But the steps aren’t concise and there’s a lot of extra steps not written.
Could you tell me more about which elements missing from GH Component/Plugin tutorials such as Icons?
I think there is another thing I think would be good as part of the tutorial: Local installation.
From the tutorial, I know how to run my plugin in debug mode, so I can use my plugin when I launch Rhino/Grasshopper from VS Code. But how do I locally install it? Like, once my plugin gets working enough for my own use in an art project I’m working on, how do I just install the plugin “for good”, but without submitting to the grasshopper package distribution system, for which my plugin is either too niche, or is not mature enough?
I see instructions on how to submit my plugin to a repo for distribution to others, but I’m looking for the middle ground, and it would be cool to have those instructions as part of the tutorial.
I would additionally suggest a change for the VS toolkit for grasshopper plugins. When I run the command
dotnet new ghcomponent -n "arst"
it makes a new file “arst.cs”, with some boilerplate code for a component. Nice! But, it doesn’t use the namespace or category as my other components.
It would be great for the dotnet command to pre-populate these, so I don’t forget. Thus, I mostly copy-paste another component instead of using this dotnet command (and because I am using the IconLoader method from that other thread, not what’s provided in the template. I would even suggest the IconLoader should just be standard, as it solves an annoying problem.).
I know this isn’t part of the tutorial, but it’s related to being new at plugin development, so I figured I’d ask for it here.
Great question. The latest templates also create Yak packages when you build and these can be drag dropped onto Rhino to install the plugins inside, this would then be permanently installed.
I’ll think about where to add this into the docs.
I have another request. I wish the template came with a launch configuration that just builds, but doesn’t launch Rhino. This would be helpful after I’m through a debugging stage and after I’ve locally installed my plugin, as a precursor to distribution.
Edit: To add some context, I’m using Visual Studio Code on MacOS, so I don’t have the “Build” menu that Visual Studio has on Windows.
Will you please help me a bit more with the local installation step? I see the /obj and /bin folders that got generated when I built, and inside I see .gha files. But I need yet a bit of coaching, please. Should I just copy the .gha file into my Components folder? (I would probably just make a symlink…) Or do I need more of the built files? Thanks!
If you reference nugets other than RhinoCommon/Grasshopper you’ll need to include those DLLs
Project References
If you create a project library and reference this you’ll need to include it.
These reference DLLs are easy to bundle when using Yak rather than sharing .gha’s
(I think) all System.Something dlls that are not nugets will be included by default with Rhino, so you don’t need to include them. e.g these 2, Rhino includes these, so there is no need to bundle them.