Comparing Lists - Return Common

This seems to be a popular topic, and I’ve checked a couple of the forum posts but haven’t been able to find a solution yet.
I’ve got two lists (pulled from element parameters). I’m trying to get it to output the common things between the two lists, but everything I’m doing is coming out empty.
I would also like to eventually get Dynamo to output the index at which the common thing is on list 2.

As you can see from the highlighting, there definitely are commonalities between the two lists, but Dynamo isn’t outputting them. Any ideas?

*Side note, anyone know why the second List.Sort didn’t actually sort the list?

Hi @jmayesP84R8 ,

Have you tried to change the lancing of the “List.Setintersection” to auto?

Yep! When I do, List.SetIntersection just returns a single “Empty List” output instead of the longest list you see above.

@jmayesP84R8 I believe there is a Type mismatch happening. Although I have "Comment: " in both the list but one of them is a Parameter and the other is a String, so the intersection is Empty.

Put the Object.Type node to verify that’s not the case with you.
If that’s the case then drop in a String from Object node and give it a try.

1 Like

@jmayesP84R8 I don’t know what your workflow is since you didn’t share the entire graph.
But if you are reading values from a file then those values should be exact.
“Comments” is not equal to "Comments " because the later has an extra whitespace.

If that is the case then you can do something like this:

@AmolShah thanks for the suggestion! You’re right, one was a string and the other was a Revit.Element, so the comparisons weren’t reading them well. I used the String from Object node (and the List.Sort worked that time), but the List.SetIntersection is still turning up empty lists.

For context, I’m grabbing some shared parameters from an Excel file (600+ parameters) and comparing them to parameters in a schedule and trying to just sort out the ones we need for particular families (“only” 126 of them). I’m hoping to be able to get the indexes of the 600+ parameters that are common between the two lists and filter out the ones I don’t need.

@jmayesP84R8 Can you change the lacing from Longest to Auto and see if it works?
If not, try looking at the Whitespace suggestion since you said Excel is involved.

1 Like

Pretty sure Lacing will be the bane of my existence.
Auto lacing worked!

2 Likes