Revit / Dynamo script sort before Set.Parameter

Hello everyone,

I’ve been trying to create my first Dynamo script for a few days.

The “Fire Alarm” category should be read from my project, and I’ve given the category families a “number” parameter. Now the script should search for everything in the “Fire Alarm” category, find the absolute Z coordinate and sort it by that.

Then the “number” parameter should be filled in sorted order from 1 to x.

I’m getting the parameter to be filled, but unfortunately not in the desired sorting order but in the order in which I placed the objects.

The upper part gives me a sorted list, as it should.

The SetParameterByName part works so far,

but unfortunately I don’t know how to get the sorting to be carried out first and then the numbering to be carried out based on the sorted list.

I hope someone can help me here and give me the solution.

Regards

Lennard

You’re so close!

Look carefully at what list you’re sorting in the List.SortByKey node.
From what I can tell, your ‘list’ input is the Z values of the location points, and your key input is the Z values of the location points.

However you’re describing a desire to sort the list of fire alarm elements by the key of the Z values of the location points.

Once you address that you’ll have a list of elements that has been sorted by the Z value. If you use that list as the input for the Element.SetParameterByName you should be all set.

Note that you may want to build sequence from 1 to the count of elements in the sorted list (List.Count node) instead of building a big list and hoping you never have more elements then that.

1 Like

To add to Jacobs List.count addition. List.uniqueitems could also be a good way to slim down that list depending on what you need. Followed by a List.count it will assign the same value to all the “Brandmelders” with the same X-Value. That way you wont have 900 + numbers.

Veel succes! / Good Luck!

2 Likes