Property of draw name of GH Components

#1

Hi everyone,

I was searching for the property of the components to change its icon to the default name via C# for a certain subcategory of components.

I can´t find how the property of this is called:

Thanks !

#3

I got it working in parts, but axactly that components(primitive/containers) I want to change do not respond:

Aren’t they in the GH_Component class? If not in which are they?

name

That’s the code so far:

 private void RunScript(bool run, ref object A)
  {

    GH_Document doc = GrasshopperDocument;


    if (run)
    {
      foreach(IGH_DocumentObject obj in doc.Objects)
      {
        if(obj is GH_Component)
        {
          GH_Component comp = obj as GH_Component;
          //test  for category / sub category
          if (comp.IconDisplayMode.ToString() == "icon" || comp.IconDisplayMode.ToString() == "application")
          {
            comp.IconDisplayMode = GH_IconDisplayMode.name;
          }
        }
      }
    }
  }

Thanks!

File:20190509_SetIconDisplayMode.gh (2.7 KB)

(David Rutten) #4

Those are parameters, not components.

1 Like
#5

Hi David,

thanks a lot!

One more questions, do I have to test for each type like this :

if(obj is GH_Param<Grasshopper.Kernel.Types.GH_Number>) 

or is there a way to check for all of them at the same time?
I tried it like this:

if(obj is GH_Param<IGH_Goo>) 

without success.

Many thanks!

#6

Just applied per Category was the easiest.
Thanks

(Andrew Heumann) #7

All params implement the interface IGH_Param, so you can test
if(obj is IGH_Param)

2 Likes
#8

that´s good to know.

Thanks a lot Andrew!