Organizing Beams by Mark

I have a script that is eventually supposed to compare beam sizes between an excel schedule and the revit model. At this point in the script, I’m trying to reorganize my list of beams so that the Marks are in order with the excel schedule. So I would have a list of beams that when the Mark parameter is taken from them it would be in the same order as the excel sheet I have. So the first beam in the element list is 2B-1 the second is 2B-2 and so on.


In this picture I’d like the parameter values to be in ascending order. As you can see I have mapped out the indices at which the elements should be placed. I don’t know how to tell Dynamo to place index 0 of list x at the number in index zero of list y. In this case place the first element in the list at index 63 of a new list.

From here I can get the type parameter( which is labeled as the size of the beam in my case) and compare it to the sizes in the schedule. Then the IF statement I set up will show false for every beam that doesn’t match the size in the schedule.

I’ve posted the script if anyone would like to take a look, but it is pretty specific to the excel schedule format I have so I will post that too. My revit model is too large to post unfortunately
FH WP Beam Schedule Second floor 1.xlsx (20.6 KB)<a class=“attachment”
Basically the “Color Red” sizes in the excel are columns I eventually want to color red so I can visualize the beams that need verification in the model.

Beam Verif.dyn (86.0 KB)

1 Like

When I try and replace at index, it places the entire list at each given index. Why doesn’t it take the first item from the element list and place it at the index of the number that is first in the index list?

List.SortByKey is the node you want. The list of elements is the list. The value for mark is the Key.

Thanks for the help, but I’m not quite there.


The list on the left has the marks taken straight from the elements as the keys. Do I need to set all the beam marks to padded values before sorting them? So its 2B-001 instead of 2B-1. Will it have them in the proper order then?

Also I tried using the already correctly ordered list of of column marks as keys and it gave me the right side list which is way out of order so I’m not sure what is going on with that one.

Wire the results of the Element.GetParameterValueByName on the left into the Keys input of the List.SortByKey node. I have no idea what you are using as a key at this point.

Thanks for helping out, and sorry about the confusion. I have plugged my list from GetParameter into the left side of the SortByKey node in the image above. The GetParameter node after the SortByKey is to show you if the list of beams is in the right order(according to Mark) after it has been sorted. You see it still has them sorted in a way that 2B-10 is ahead of 2B-2 and so forth. In order to compare it to my excel schedule without editing the sheet in excel, I would need it in 2B-1, 2B-2, 2B-3…order.

My guess would be to rename the Mark parameter using the script so each mark has the same number of digits. ex 2B-001,2B-002 etc. Then I could get the parameter and use it with SortByKey.
Do you think that is the best way to do it?

The list on the right side of the picture was my attempt at sorting the marks numerically in a list before entering them as keys to SortByKey, but it didn’t seem to get the desired result.

Ah! I see the issue now.

Personally I hate having to adjust a mark to make the process work, specifically when it leads to marks that are (prefix grouping)-(padding zeros)(actual mark number).

Try this:
Split the string from the mark at the “-” character.
Take the second item in each list and pad it with zeros. (String.PadLeft) to make all strings the same length. Then join the first and second item in each list with a “-” between them. The result should be sortable natively and won’t require adjusting marks (though this string could be used to adjust the mark if you wanted to do so).

Right! If you take a look at the first screenshot I posted, I took that list of the marks that i split, reordered, and put back together that is shown in the bottom Watch node(2B-1, 2B-2, 2B-3) . I plugged that into the second Sort by Key node in the screenshot above. That is what you are suggesting right?

The results for that were something I couldn’t understand (2B-7,2B-14,2B1…). Does the GetParameter node return those Marks in a string? To get the marks to not have extra zeros in some places I had to convert to a number to sort and then back to a string, I was thinking that could be the issue. I don’t have my work computer with me to show a screenshot, but if you open the script I attached you could see the methodology I used.

Thanks again for helping out.