Simple Instructions for adding an Icon to a Mac C# Grasshopper Component

I’ve tried a lot of different ways of adding an Icon to a Mac C# Grasshopper Component but I really don’t get it. I’m not a pro-coder but I thought I was fairly ok…

I’m working on a MacBook Pro in Visual Studio
I have no problem making components that work
BUT I really can’t get an icon to show up

I’m fairly sure that I’m not properly adding a png icon as a resource
Because it never appears in the auto-prompt when I type

Please can someone help me out with some idiot proof instructions that work on a Mac!!

Thanks!

below is the method i found after trial n error:

  1. add your icon image to the project directory
  2. right click on that file and set Build Action > Embedded Resource
  3. add resource file to your project (by right clicking)
  4. modify your resource.resx xml accordingly to contain the resource icon name. attached is my resource.resx file. I’m not too sure about what publicKey to put, i happen to copy from the windows version of my component.
    resources.xml (6.9 KB)

hope it helps!

Also, if you don’t know, it is important that the icon is exactly 24x24 pixels.

1 Like

Hi Verina and Micheal,

WOW it worked

Thanks for the info!
I think the editing the resource.resx was where the confusion in my head was

(Let’s pretend that it isn’t just me…)
Just to make it a little clearer for other people I’ve:

  1. placed using the Mac [File] Finder an 24x24 pixel png image icon (called named_icon.png) in a new folder called “resources” in the folder called “Properties”
  2. added the icon to the project directory by drag and dropping it on the “Properties > resources” folder in Visual Studio
  3. right click on the added icon file and set Build Action > Embedded Resource
  4. added resource file to the project (by right clicking on the “resources” folder in Visual Studio) selecting Add > New File… (in the pop-up that appears) Misc > Resource File
  5. the file resource.resx opens and the xml code is modified to include <data name=“icon” […etc…] from your file just above the final line
  6. left the PublicKeyToken alone (seems to work like that)
  7. added this line to my .cs code > return Properties.resources.Resources.named_icon;

(next time I’ll name my folder icon_folder to be less confusing)

Thanks!