Access connected grasshopper canvas components

I’m trying to integrate an external program I’ve written via calling a new process. I’m using python to call the program from within GH. I’d like to get some quick visual feedback on the state of the output and one way I’d thought of is to change the colour of the connected panel. At some point I saw somewhere that you could access the inputs and outputs of the current component, but I can no longer find the example. So ideally what I’d like to do is change the color of the connected output panel. If there’s no errors, set the shown panel color to green, if there are errors, set it to red. Is this possible, or am I barking up the wron g tree? Any help greatly appreciated.

Yes, it should go something like this (written on phone, not tested) :

import System.Drawing as sd
from Grasshopper.Kernel.Special import GH_Panel

custom_color = sd.Color.DeepPink 
error_param = next((p for p in ghenv.Component.Params.Output
                    if p.NickName == 'errors'), None)
panels = [p for p in error_param.Recipients
          if isinstance(p, GH_Panel)]

for panel in panels:
    panel.Properties.Colour = custom_color

See this list for possible colour choices or define your own using sd.Color.FromArgb()

1 Like

Yeah, that worked. Thanks a bunch. I knew I’d seen it somewhere.