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)
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.
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
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.
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)
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.
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
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.
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.