Group common items into sublists

Hi Everyone,
I’ve had a few searches and though there are plenty of topics related to this I can’t find the answer to my question.

I have a list of pipe diameters related to individual elements within my model and I would like to be able to group these into sublists so that I can count them and replace the sublist with a string showing the count by the first sublist item, and then i’d like to concatenate those outcomes so I have one list item per element related list.
Below is an image of the list I have and what I want to achieve;

The list structure needs to remain the same as I need to write the outcome back to a parameter within the element, so it needs to match the list structure of the element.

I’m just struggling to to group common items within a list into a sublist. If I can achieve that i can then count the items in the sublist and add that to the front of a string using the first item in the list and then only keep that first item. Then concatenate the list items again to get to my final step.

Any help or suggestions would be much appreciated.
Thanks

I think the results you are looking for can already be achieved using Revit schedules? Is there a reason you want to do this through dynamo?

In any case, try the List.GroupByKey node.

It’s part of a larger graph that’s reading various bits of info and then writing them back to elements to be scheduled.

The list of pipes related to the elements are read by creating some temporary geometry using dynamo and then using the geometry.doesintersect node, so I guess i’d have to use dynamo to get the list of related pipe sizes and then write them individually to the element somehow, then schedule them in revit to be able to group them and then write them back to the element to be able to schedule from the element with other parameters. So it would be much neater if I can achieve this all in dynamo, that way I can run my script to occupy the parameters in the elements and have one schedule to read it all.

I have found this Clockwork node which can split out common items within sublists and give the count. I now just need to figure out how to take this data out of the lists and concatenate them into strings to reach my goal;

Also, i’m not sure how the List.GroupByKey node works? Could you please explain what the key would need to be?

Here it is …

In the end play with spaces and comas to get the results…

1 Like

It seems you already found a better node, and @saju_autodesk understood better what you wanted to do. Hopefully you can achieve your intended results now :slightly_smiling_face:

Here is the complete graph…!

Brilliant! Thanks.

Though i’m struggling to read what the last node is and i can’t enlarge the image?

“Convert List to Comma Delimited String” from Bakery package.

1 Like