Sort Revit Elements by Number then Letter

Hi,

I’m trying to sort Revit Elements by number then by letter. I would prefer to only use Dynamo and no Python.

The Revit Elements have a parameter for each i.e. loadNumber = 1, loadLetter = A. My resulting Element need to be sorted somthing like this:
1
1A
1B
2
3
4
5
6
7
7A
7B
8
9
10
10A
10B

When I SortbyKey using the loadNumber, it works. When I then try to SortbyKey for the loadLetter it doesn’t work. Seems that SortbyKey is using numbers only.

GRAPHIC COLUMN AND WALL SCHEDULE GRAPH.dyn (95.8 KB)

GRAPHIC COLUMN AND WALL SCHEDULE.rvt (2.6 MB)

Thanks Andreas for the quick reply. I need to explain myself further. I’m looking to sort the ‘Revit Elements’. I am able to sort ‘the list’ adequately by combining the two strings and then using list.sort. What I’m finding is that I’m able to get a sorted list but not sorted ‘Revit Elements’. I want to pull more parameters from the sorted Revit Elements after I have organized them by number then letter. Hope this makes sense.

This fits into a bigger picture of trying to make a custom Graphical Column and Wall Schedule.

You’ll have to sort your lists twice. Rather than using the parameter values as the list input as well as the key values, use the element list instead.
image

Thanks Nick. As you can see from the Graph that I posted, I did plug the Element list into the ‘list’ input.

It gives an error ‘Warning: List.SortByKey operation failed.
One or more input types are not matching. Lists as keys are not supported.’

Just as the warning says, keys cannot have sublists. You’ll either need to flatten your lists or use levels.
image

The lists match, maybe this graphic will help.

Here’s another version I tried…

Your list of keys going into the second SortByKey is a list of lists. This is not supported for keys. You’ll have to use levels.

Thanks, looks like we’re getting closer by pressing ‘use Levels’. Any ideas on a next step?

You need to pick the correct level(s) to get the lacing you’re looking for. Levels are just the list dimensions in an output. You can see at the bottom left of the preview (or watch node) the levels available in that list. Iterating the keys input over a level 2 list in this case will run each sublist like its own list of keys.

Thanks, this is on the right track for sure. It must be some combination of lacing and levels. See if this makes sense…

Can you post an image of your whole graph, or at least the part showing how you got the parameter values initially? I’m confused as to why your lists don’t match in the first place.

@jay.polding See if this solves your problem
20170826-1.dyn (13.0 KB)

Thanks Vikram,

Although your Graph does produce a list, it is just a list of Strings and not a list of Elements. I’m looking to sort the Elements so I can work with them further. For instance, I would like to getparameter for Family Type or Mark or some other parameter.

Thanks so much for looking into this issue Nick, I have attached the images as well as the graph.

3

GRAPHIC COLUMN AND WALL SCHEDULE GRAPH.dyn (96.2 KB)

You need to sort them by letter then number.

Elements are sorted. The strings only serve to demonstrate that.
Note that the strings are parameters obtained from sorted elements.

The sorted list output port on the last SortByKey node in my graph gives you a list of sorted elements (You can flatten the list, if you want)

1 Like

Sorry about that, yes your method did Elements. Thank you!

1 Like

Question for you two, why would I need to sort by letter and then by number? Why would I get such a different result the other way?