Change the icon of a component according to a parameter

Hi,

I’m trying to design a new grasshopper component and I would like to know if it’s possible to change the “logo” or the “icon” of this component according to a parameter ?

For example : If the input of this component is “1”, the icon is a picture. If the input is “2”, the icon is another picture.

I use C# and Visual Studio Community 2017.

Thanks a lot.

Mathis

Hi Mathis,

you can change icons for the display of your component on the canvas, it’ll be much harder to make it change on the ribbon.

The easiest solution is to call the SetIconOverride method on your component and provide a 24x24 bitmap.
You can also make the Icon property return different images based on some state, but remember that you have to call DestroyIconCache() when you do otherwise the component will keep re-using the previous icon.

Hi David,

Many thanks for your help.

I will try it and let you know if it work.

Hello,David,the SetIconOverride method exist in rhino7’s grasshopper,but it seems no exist in rhino5’s grasshopper,so how to do this in rhino5’s grasshopper?(because i need it support rhino5),thank you!