Managing Lists in Python

Hello everyone,

I am using a python node to calculate a value to be applied to some areas in Revit.
This is the Output i could reach and now I am stuck. The value in index 0 should be applied to all Areas in index 1, 1 to 2 and so on (the list lenght is variable). I dont know if i could have organized it better inside the python node, or if there’s a way of separating the Elements and values from the Output with Dynamo nodes… Would appreciate some help here! Cheers!

Hi ,
I don’t understand from what you wrote - what output would you want ?

Hi Jonathan, I want to separate the lists i get from the python node Output, so that i can connect them to the Element.SetParameterByName node. So I want to get a list with values and a list with a list of areas. Does that make sense?

Not a 100% sure,
If I understand correctly you are trying to set the “Dynamo NRF” parameter, which is the 0 and 2 elements to each of the Area objects ?
If so - I think it’s just easier to set the parameter in your python script - use a nested loop .
You need to start a transaction , and use the SetParameterByName function
have a look here -
hope this helps

2 Likes

I agree with Jonathan’s approach of setting the parameter values in the Python script. If you really want to do it externally using a regular Dynamo node, a common way of managing multiple outputs in a Python node is to just wrap them in a single list and split them afterwards. For example:

elements = IN[0]
values = IN[1]

# Other code here

OUT = [elements, values]

You can then take that output and write a simple code block:

data[0];
data[1];

This will create a single input called data and give you two outputs where data[0] is your list of elements and data[1] is your list of values.

1 Like

I would agree with everyone else that setting the value with python is probably the easiest way to accomplish this. That being said, I tend to output both the values and the elements when working through a new graph as it lets me double-check myself and see the values I’m working with. You may also need these values downstream. It all depends on what you’re doing and how you want to do it.

1 Like