Override Colour based on a Sorted and Filtered List of Revit Category

I’m trying to create a script to select all elements of a Revit category (windows), sort by a shared parameter (room number), filter that list based on a second list of a different Revit category (rooms) (also sorted by room number) and then override the colour of the failing windows. Everything works fine until I get to the colour override.

When I use All Elements of Category instead of my sorted list it works, but it overrides the colours of the wrong windows as the list is organised by when they were placed in the model, not by room number.

Any help would be apricated.

The start of the script is this

Hi BR2020!

Could you show the error message in the nodes?

You are supplying numbers as element which is why it’s not working.

Filter the elements as required and supply them to the SetParameterByName node.

Thanks! I got it sorted. The solution was to sort the elements before extracting any parameter information