Add a custom icon image to Grasshopper plugin tabs

Thanks @Michael_Pryor for helping wrap our minds around this. Here is how I ended up using your recommendation with code, just because I’m not using VS.

using System;
using System.Drawing;
using System.Linq;
using Grasshopper;
using Grasshopper.Kernel;

namespace Plugin_1_Day_3
{
  public class Plugin_1_Day_3Info : GH_AssemblyInfo
  {
       // all the name, icon, description, guid, etc stuff...
  }
  public class CategoryIcon : Grasshopper.Kernel.GH_AssemblyPriority
  {
    public override Grasshopper.Kernel.GH_LoadingInstruction PriorityLoad()
    {
      var assembly = System.Reflection.Assembly.GetExecutingAssembly();
      var resourceName = assembly.GetManifestResourceNames().Single(n => n.EndsWith("AverageIcon.png"));
      var stream = assembly.GetManifestResourceStream(resourceName);
      Bitmap dasIcon = new Bitmap(stream);
      Grasshopper.Instances.ComponentServer.AddCategoryIcon("Workshop", dasIcon);
      Grasshopper.Instances.ComponentServer.AddCategorySymbolName("Workshop", 'w');
      return Grasshopper.Kernel.GH_LoadingInstruction.Proceed;
    }
  }
}

image

just wrapping things up after looking at this thread, being able to make icons makes all the difference!

2 Likes