Revit -> Sorting Lists with Dynamo for Excel-Export

Hey there,

i am trying to get a few lists from Revit to Excel. This, for now, works fine.
The result i am Getting looks like that:

A B C D X Z
B D O Y Z
L N Q R U X

Is there a chance of getting the lists into the following order:

(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z )

A B C D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 X 0 Z
0 B 0 D 0 0 0 0 0 0 0 0 0 0 0 O 0 0 0 0 0 0 0 0 0 0 0 Y Z
0 0 0 0 0 0 0 0 0 0 0 0 L 0 N 0 0 0 Q R 0 0 U 0 0 0X 0 0

Thank you in advance :slight_smile:

Something like this?

Capture

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import string

input = IN[0]
	
def list_me_alphabet(list):
	list_new = []
	for item in list:
		li = item.lower()
		list_new.append(string.lowercase.index(li))
	
	output=[]
	for n in range(26):
		if n in list_new:
			output.append(input[list_new.index(n)])
		else:
			output.append(0)
	return output

OUT = list_me_alphabet(input)
1 Like

Thank you for your quick response. The Output looks like the result i am looking for, except that i want all my lists look like that.

Else I wanted it to include not all of the “alphabet” or “listentries”, but only those that really do appear in the lists - without typing them down, to be usefull with different lists also.

so (just) loop that function I wrote?

Capture

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import string

input = IN[0]
	
def list_me_alphabet(list):
	list_new = []
	for item in list:
		li = item.lower()
		list_new.append(string.lowercase.index(li))
	
	output=[]
	for n in range(26):
		if n in list_new:
			output.append(list[list_new.index(n)])
		else:
			output.append(0)
	return output

dump = []
for list in input:
	dump.append(list_me_alphabet(list))

OUT = dump

Thank you again @3Pinter!

Your Code says, that you assume that there will be max 26 different items in the lists. I am looking for a solution that, in your case, just uses the number of items available (3 lists with 4 items summed up 12 items).

Else i would be very pleased, if there is a possibility to do it without using IronPython since i’m using Revit/Dynamo in an Citrix environment.

This codeblock should work:

listbool = List.Contains(x@L2<1>, abc<2>);
listbool@L2<1> ? abc : 0;

Should work with any length of alphabet and any order for the list.

Hey @kennyb6, thank you for your quick response.

Since i’m really new into Dynamo, i guess i need some more help…
Tried to use your Codeblock, but i can’t get it running properly… (invalid associative_number)

image

Ah you are using Dynamo 1.3 or earlier, the code I wrote was made in Dynamo 2.0

Is it possible for you to upgrade to Dynamo 2.0, or at least 1.3? If you are using Revit 2017-2019, you really should be using 2.0. I can’t test for 1.3 or earlier at the moment.

Oh heck… thanks again!
You are totally right. Just noticed that i’m on Dynamo 1.2.1
Trying to get the latest Update now… Will keep you informed.

Upgraded to 2.0 today and now the skript works perfekt. Exactly the output i was expecting. Thank you so much @kennyb6 !

But now i got a problem i haven’t thought about before…
Since now i was using “List.CountOccurences” to get from an AAABBDDDD-List that ABD-List and a 324-List.
Now that List of occurences doesn’t fit the new “AB0D”-List anymore. Didn’t figure out how solve that new Problem :frowning:

Can you show what the structure looks like and how you would want the results to be? There should be quite a few ways to do this.

Going off of the structure from the previous post, this would work to count them:

I am exporting it to Excel and want it to look like that:

At the moment it looks like that:

image

Is there a reason for that list structure? You are repeating the A, B, C, etc within the data as well as the header? The bottom part of the rows, where it is just numbers (3, 2, 0, 0, 1, 0, 0, 2, 0, 0, 0) is not a problem but the A B 0 0 E will make it unnecessarily more complicated.

Actually you are right, if there is an easier way without the A B 0 0 E it will be just fine

Let me know if this works:
countingchars

Python script:
OUT = map(lambda chars : [x for x in chars], IN[0])

The last node uses Keep List Structure as checked (highlighted blue). You can do this by clicking the > next to list, checking Use Levels and Keep List Structure. Then you have to save the graph, close it, and reopen and it should be blue.

Version without python if it makes it easier:

Works perfectly - Execlty what i was looking for.
Thank you so much @kennyb6!! :smile: