SOLVED: Create Data Structure w/ Panel Name (Combining Nickname with Dynamic Input Value via Python)

I’m looking for a good way to combine data streams into a logical output (I’m sorry if that description is too vague, but I hope it’s evident from the screenshot what I’m trying to achieve.) I believe I only need to replace the highlighted code with something like “s.Value” in order to get values from each of the inputs?

Thanks for any help you can provide. I can find my way around rhinoscriptsyntax, but this stuff is over my head :roll_eyes:

Alternate methods also welcome.

Current code:

 # https://www.grasshopper3d.com/forum/topics/python-get-label-name-of-input-components
info = []

for input in ghenv.Component.Params.Input:
    for s in input.Sources:
        ### edited code
        attr = s.Attributes
        if (attr is None) or (attr.GetTopLevel is None):
            pass
        else:
            component = attr.GetTopLevel.DocObject
        ####
        info.append(component.NickName)

a = info

Hi Steven @senorvalenz

please attach samples if you would like people to try your code.

I think I understand what you are trying to do. In general, reproducing value evaluation is very difficult, and should be Grasshopper’s task. It’s better to let Grasshopper compute, and create data with what is given. For example, this way will work:


naming.gh (12.9 KB)

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Thanks for your reply Giulio, and sorry I wasn’t more clear. I’ve clarified my goals with a screenshot and attached my Rhino and Grasshopper files. Does that make more sense? Please pardon the mess, it’s very much a WIP!

GrasshopperSandbox.3dm (66.1 KB)
GrasshopperSandbox.gh (59.9 KB)

I think this produces your desired outputs:

combine_NickName_w_input_value_re.gh (8.4 KB)

Script raises an exception if all inputs are not the same length and gives a warning if inputs are not set to “Tree Access”.

-Kevin

This is perfect, thanks so much Kevin. I’ll have to dig into the code more closely to see how I can improve my future scripts. :pray: :pray: :pray: