Get all inputs variable Names and Values in a Python component

Hello all,

I’m strolling to get the values of all inputs and use them inside the script itself.


for input in ghenv.Component.Params.Input:
    print input.Name

I can get the names of all inputs, but using:

print input.VolatileData.AllData(True)

doesn’t let me use the value.

If I create a variable as a = input.VolatileData.AllData(True) and output that variable it works, but I really need to iterate over all components, and use the values inside the script.

I’m sure it is something really easy that I’m missing.
Thank you (6.5 KB)

I solved it myself.

here is the code I used:

for input in ghenv.Component.Params.Input:
    for s in input.Sources:
        attr = s.Attributes
        if (attr is None) or (attr.GetTopLevel is None):
            component = attr.GetTopLevel.DocObject
            print input.Name
            print component.NickName
            if type(component) is gh.Kernel.Special.GH_NumberSlider:
                print component.Slider.Value    

hope it helps someone with the same problem as me. (4.3 KB)

1 Like