Looping through elements to set a parameter

Hi,

Explanation: I am trying to create a tool that will automatically recolor elements within Revit. The set parameter by name function does not work with a list of elements, but individual index items do. So, I created a loop to go through each indexed element individually and send it to the function.

Problem: Only the last indexed item of the list gets through to the set parameter function. I suspect that the loop is correct and runs independently through each value 1 by 1, but it is not running each of those values to the set parameter function. Any suggestions?

Thanks in advance for your help,

Element.SetParameterByName … input the whole window-list

Value: a same length list .?

SetParameterByName will work fine with the correct list structure. The “fool-proof” way to do this is with the exact same number of items in the exact same list structure, but it can also be done with list levels using the appropriate structure. Can you show us your input lists for the node?

Here are the inputs. So if I’m understanding both of you correctly I need to create a list of equal size which only contains the material I’m applying as an input to the value?

Can you show the list previews please? We need to see the existing list lengths and structure.

Is this what you need to see?

Kinda, but your GetItemAtIndex node is failing so that doesn’t really help. Let me see if I can draw up an example.

Ah, fixed that issue, the list count was 1 too high. Here is what it is showing now

Just so I’m clear on what you’re trying to do here… You want to assign one material value to that list of material parameters for an entire list of elements. Is that correct?

Yes that’s correct.

Dynamo nodes will automatically try to loop or iterate through lists of inputs, but they do so differently depending on how the node is setup to handle lists. I won’t get into that here, but you can look into it if you’d like. The SetParameterByName node can already handle multiple parameters, so we can use list levels (at level 1) to specify that each element should be treated as a separate input. In doing so, Dynamo knows to apply the parameter value to each parameter for that one element (like it does on the bottom portion.) It now does that for each element in the list automatically.

Thank you very much for your help, that worked. I just picked Dynamo up this week so I did not understand that distinction.

Here is the final working version for any others that might need it.