i would love some more help here… can u guys help in more detailed way?
Mike, thnx in advance…
This is a really nice c# workshop about plugin developement with visual Studio from the ICD Stuttgart.
All material can be downloaded and all 3 days were recorded. I think somewhere in day 2, it’s explained how to do it.
im looking on adding plugin TAB logo … struggling here
Yes I know. I won’t watch 6 hours again to tell you at which point he shows it…
But I’m 100% sure Long Nguyeny shows how to do it.
2:18:40
Glad you found it
Are you using visual studio?
If so to add the plugin tab logo you will need to add a new class
Mine looks like this:
public class PufferfishCategoryIcon : Grasshopper.Kernel.GH_AssemblyPriority
{
public override Grasshopper.Kernel.GH_LoadingInstruction PriorityLoad()
{
Grasshopper.Instances.ComponentServer.AddCategoryIcon("Pufferfish", Pufferfish.Properties.Resources.PfCategoryIcon);
Grasshopper.Instances.ComponentServer.AddCategorySymbolName("Pufferfish", 'P');
return Grasshopper.Kernel.GH_LoadingInstruction.Proceed;
}
}
OK. managed…
i’ve been banging my head against this problem for a while. I’ve made a simple plugin here to try and problem solve why the Category Icon never displays.
What am i doing wrong?
I’ve done the following:
- created a new project using the template
- added a new class as per @Michael_Pryor
- added a 16 pixel and 24 pixel png image to the project resources
- tried setting icon to
Embedded Resource
zipped VS solution attached below
MyProject1.zip (554.1 KB)
Any tips welcome!
Try adding Michael Pryor’s block of code to your “MyProject1Info.cs” file
Thanks will, I tried your suggestion, but no difference. I’ve already had the following code in Class1.cs in the project attached to my OP
using Grasshopper;
namespace MyProject1
{
class Class1 : Grasshopper.Kernel.GH_AssemblyPriority
{
public override Grasshopper.Kernel.GH_LoadingInstruction PriorityLoad()
{
Instances.ComponentServer.AddCategoryIcon("MyProject1", Properties.Resources.smile_16);
Instances.ComponentServer.AddCategorySymbolName("MyProject1", 'M');
return Grasshopper.Kernel.GH_LoadingInstruction.Proceed;
}
}
}
The image needs to be 24x24 not 16x16 if I remember correctly. Also, I use a public class.
Spot on Michael I missed that detail. The above works as expected when the class is made public.
Hello
can you please explain in detail how to add a picture to the bar menu
I did as you created the class and announced the fields in the resources but the equal picture is not added?
can you please post the full example from VS 2019?
using Grasshopper;
namespace ToolBox
{
class LogoToolBarMenu : Grasshopper.Kernel.GH_AssemblyPriority
{
public override Grasshopper.Kernel.GH_LoadingInstruction PriorityLoad()
{
Instances.ComponentServer.AddCategoryIcon(“ToolBox”, Properties.Resources.Logo24x24);
Instances.ComponentServer.AddCategorySymbolName(“ToolBox”, ‘S’);
return Grasshopper.Kernel.GH_LoadingInstruction.Proceed;
}
}
}
Resources
internal static System.Drawing.Bitmap Logo24x24
{
get
{
object obj = ResourceManager.GetObject("Logo24x24", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
You also have not made your class public…
thank you very much for the answer!
I didn’t notice, but as I added it began to compile
but now another problem
now such a window crashes when loading
or I incorrectly connected the resource file?
I don’t add resources by code. I add them with visual studios resources folder. Then be sure to set them to embedded resource.
Thank you. Great. Everything worked out !!! Rays of Gratitude it all worked
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;
}
}
}
just wrapping things up after looking at this thread, being able to make icons makes all the difference!
Can this be done for a Python only plugin?