Sort List by Index or KeyList


#1

The overall problem is to take in all the door elements in the project, sort them by level and then re-number the doors sequentially. I have managed to grab the elements, extract the parameters I need (Unique Revit ID, Level, Mark) and lace them into a list of lists so that each door is its own list.

 

The problem I’m having is that it will not sort by level. When I get the parameter level Dynamo spits out the unique Revit ID of the level so in my list of 300-ish doors there are 8 unique levels. I think maybe I don’t understand the “keyList” or “keyProjector” parameter. I am trying to feed it the function GetItematIndex that points to the index of the level.

 

What is a keyProjector?

How do I sort a list of lists based on a particular index of the sublists?

Is this the right method to renumber doors sequentially?

 

Help would be appreciated.

Capture3


#2

Sounds to me like you don’t actually want to sort by the level, but rather by the elevation of the level. The key projector of SortByKey needs to be a single node, so you could wrap two nodes like Element.Level (from package Clockwork) and the built-in Level.Elevation into one custom node and use that as your key projector, like so:

sortbykey

I have just added this node to package Clockwork. Also, you may be interested to look at some more sorting / numbering examples:



And I think Konrad Sobon also has some sorting/numbering workflow(s) on his blog: http://archi-lab.net


#3

Thanks that is very helpful. I downloaded the github examples as .DYN files but when I try to open them in Dynamo nothing happens - the screen stay blank. How do I view the example workflows?


#4

I’m on 0.7.5 RC2 and I can open them just fine. Maybe it’s the browser download? Perhaps try downloading the whole repo (https://github.com/CAAD-RWTH/ClockworkForDynamo/archive/master.zip) instead.