Produce a new list with elements that are only present in both list1 and list2

Hello I am new to dynamo here and I have coding background.
I am trying to make a new list to select objects that is in layer “10” and is a line.
base on the description from chatGPT I am assuming I need to check if the list 1 for list.contains elements of list 2 and output a boolean list to feed into list.filter by boolean.

there is 11 lines total and 3 in layer “10” and 1 polyline in layer “10”
the output for list.filter have in as empty and out containing one polyline

Hi @jeff.wangD95HG ,

Dont use ChatGPT for Dynamo.

Based on your title: use List.SetIntersection.

However, comparing like this is cumbersome and requires awkward logic and quite a bit of calculations, why not get all objects on layer 10 and only keep the lines using List.RemoveIfNot (or vice versa)

1000 times this.


setintersection gives an empty list.
I am positive that there is 3 line object on layer “10”

well I am trying to create a generalized robust case to test out what dynamo can do and not working on workflow optimization yet.

If you want to see if they intersect, use the Geometry.Intersect instead but first convert them to dynamo geometry.


intersection in terms of lists means the common elements between the 2 list
meaning a list of [1, 2, 3] and [0 , 5 , 6 , 3 , 7, 10 , 1] the intersection will be [1,3]

I am assuming
object is a list of object IDs that fits the description
so I am just intersecting two list of object IDs to create a list of object ID that is a line and in layer “10”

It’s a little bit different in Dynamo
I don’t have a programmers background and started with Dynamo so I don’t think the same way, but when I start to learn about Python I find out that I understand more now after some practicing in Dynamo that I did before.

So what you want is objects of the type Line that is on layer 10?
Like this? This script select the four lines on layer 10.

ok thanks that is exactly what I am looking for.
ChatGPT offered similar direction

Niice no worries
Oki, but leave ChatGPT. This community is much more friendly and helpful :wink: