Merge sublist by common data to create a condensed list

firstly sorry for the long post ahead!

So i have created a set of door families with a series of shared parameters on doors (some type and some instance). these parameters are the fields that make up our standard NBS specifications.

i have used dynamo to extract all of the data for each parameter and format it into the NBS clause. now what i want to do is combine the lists that have the same data to produce a condensed version.

so for example:

i want the spec layout to contain all of the fields with only door mark to combine. so for example…

Door ID: A, B, F, G etc

effectively i want to merge only list where all of the parameters are the same except the door mark.

hopefully this makes sense?

i have posted a screenshot below of my script so far. it manages to grab all of the parameters i want and formats them into a clause for each door. it just the simplifying i cant manage…

any help would be Massively appreciated.

Thanks in advance to all you wizards out there!

Given it some thought. what i am trying to do is group the doors together where all of the items are the same (except the door mark).

the intention is to effectively create a single clause which would apply to multiple doors.

List.GroupByKey and ListLevels should do the trick. If you have more than 3 parameter values it’s likely faster to get all parameter values, convert them to strings as needed, and concact them into a ‘super parameter,’ and then use that as the key in the List.GroupByKey as you’ll only have to go to the parameter values once.

Lacing will matter in both cases.

Hi Jacob, i think grouping by key is the right way to go although i just cant seem to get it working.

I am running a test revit file so i know exactly how many doors i should have before and after the script. i.e. how many doors are in the project and how many clauses i should output.

do you have any screenshots you could attach to demonstrate?

Here is an illustration of what both the option of subsequent group by key nodes and a single string build would look like. I’ve abstracted a little to demonstrate the concept - you’ll have to apply the concepts to your case to build either option on your own.

For what it’s worth I do prefer option 2 for anything beyond 2 values - it’s more efficient to build and runs faster at that point as you don’t have to go to the well repeatedly.

Hi Jacob, the string group by key system has worked perfectly! i think it was a brainwave to realize that converting the data from the fields to strings allows you to work with and treat them differently.

there is probably more efficient way of doing the script. but at least it works!

thanks again

Door NBS Clause & Ironmongery Sets Creator.dyn (419.3 KB)

1 Like