Collect same items from different sublists

Hey there!

I’ve been struggling with this question for a while. I’ve made an Excel document with different building types (A, B, C, etc) with their building number (D001, D012, A037), see the first picture below. Now, what i want is the following: I imported this information to Dynamo and it gives me the list that’s shown in the second picture. However, I would like to get a list like the one in my last picture. Dynamo should filter out all subtlists where list 0= A (building type) and provide me with a new list. in which the original second sublist (list 7.1, 8.1, etc) is given. So, something like: 0 list --> 0= A, 1= D001, D012, A037 until J177.

I hope someone can help me out, thanks in advance!

image

Try using a GroupByKey where the key is the first list (A, Asp, etc).

Hi,

You can try to do something like :

  • Replace List.AllIndicesOf by List.Contains
  • Then filter all the lists that contains “A”.

Going off @mellouze, you can try something like this:

Codeblock:

newList = List.GetItemAtIndex(x@L2<1>,0)=="A"?
List.GetItemAtIndex(x@L2<1>,1):null;
List.Clean(newList,false);
1 Like

@kennyb6 and @mellouze
Thanks for the fast replies!

The last one did the job! Great to see it’s working!

Thank you :slight_smile:

Unfortunately, I was too fast with my reply.
I’ve been testing some different building types and the code block seems to filter out all the previous letters in the building number as well.
In the picture is shown that when I use building type D, the building number B and C are filtered out of the list (A isn’t in this list, but I assume that would be filtered out as well) , while they do have the same building type.

@Jonathan.Olesen Sorry for asking, but what do you mean with the arrow? :thinking:

That is the output you want to connect with your watch node…

You’re taking only the output of the first line of the codeblock not the “final” result…

The final result is shown in the list below the Code Block!
This watch node is for showing that it already gives a null in the first line

I see, did not understand what your problem with the “if” statement was (guess the description and the use of a dataset of 300+ values for testing confused me :wink: )
Anyway my guess is that either your “B” items etc contain e.g. a trailing space or something like that… making the value “false” even though the letter is "B "…
Have a look at this, just another way to Rome:

Better shown with the trailing space here:

You could try and count the length of your “A”, “B” etc… if the string is longer than 1 then there is an error at some point up stream of your data.

Hahah its a dataset from a real project, so thats why its that big :wink:
Thanks for your suggestion! However, the same mistake seems to appear…

What I would do is to pull out list number 48… And test the values in there (alone).

Useful nodes:
Object.Type
String.Length
x[48] - In a codeblock

Let us see what is going on, my hunch is still on trailing spaces :wink:

Alternatively supply the excel and .dyn file and I’ll give it a shot :slight_smile:

Thanks for your help! The whole script is pretty big. I hope you can help me out! The groupe called Name (where this is all about) should replace the manual name parts in each “Type” Groupe in this script.

sheets kopieren vanaf assembbly.dyn (397.7 KB)
export.xlsx (21.4 KB)

Not gonna say why, but cannot open your graph, it crashes both my Revit 2018.3 and Revit 2019.1 (Both Dyn 2.1.0)…

Gonna give it a go starting from scratch :wink:

Cannot replicate your problem…

1 Like

I’m currently using Revit 2018.1 and Dynamo 2.0.1, but I added a screenhot :slight_smile: The script is about copying sheets from an assembly, with this name as prefix instead of the manual prefix which is in there at this moment.

Thanks for trying! Pretty sure I’m doing the same things as you do, but with a different result :fearful:

Guess I found the mistake! I used the Read Excel node, while the Data.ImportExcel node did the job. Not sure why, but it works now !

Glad you got it working, please mark a solution :slight_smile: I would suggest post 3 :slight_smile: