Check matching items in the list

Hello guys, I am searching for solution how to get the index of the right list , matching in a left list (check the lists with the same indexes). Tried making a cross-product of function “==” but the lists on the left are checking all the lists on the right instead of the list with the same index :(. I hope somebody could help

I think the == node was right. Use longest lacing, enable levels to ensure you are looking at the sub-lists in your longer list.

1 Like

I think you just need to flatten your first list. The list structure should be one item per sublist.

1 Like


Flatten is not suitable because it will check all the members of the second list and if there is 2 exact members I will get bad results. It should check only sublists with the same index.
Btw, thank You for fast replies :slight_smile:

something like that?

import clr

clr.AddReference(“RevitAPI”)
clr.AddReference(“ProtoGeometry”)
clr.AddReference(“RevitNodes”)
clr.AddReference(“RevitServices”)
clr.AddReference(‘RevitAPIUI’)
clr.AddReference(‘DSCoreNodes’)
import DSCore
from DSCore import *
import Autodesk
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
import RevitServices
from Autodesk.Revit.UI import TaskDialog
from Autodesk.Revit.DB import *
from Autodesk.DesignScript.Geometry import *

#The inputs to this node will be stored as a list in the IN variables.
numberList= IN[0]
searchforList=IN[1]

test=

for x in numberList:
temp=
for p in x:
if p in searchforList:
temp.append(x.index(p))
else:
pass
test.append(temp)

OUT =test

Big Thanks for Your effort. I tried to apply this to my project.


The problem is that (due to lacks of my python script skills :frowning: ) I need to check items with the same indexes of sublists (not flattened). I hope there is a way to get the result with build in nodes. Of course Python script is a solution to this but I am not too experienced at this.

I cannot attach the test :frowning: Wanted to simplify it by adding a project
image

image
empty list is added if searched number isen’t in the numberList

> import clr
> clr.AddReference("RevitAPI")
> clr.AddReference("ProtoGeometry")
> clr.AddReference("RevitNodes")
> clr.AddReference("RevitServices")
> clr.AddReference('RevitAPIUI') 
> clr.AddReference('DSCoreNodes') 
> import DSCore
> from DSCore import *
> import Autodesk
> import Revit
> clr.ImportExtensions(Revit.GeometryConversion)
> import RevitServices
> from Autodesk.Revit.UI import TaskDialog
> from Autodesk.Revit.DB import *
> from Autodesk.DesignScript.Geometry import *
> 
> #The inputs to this node will be stored as a list in the IN variables.
> numberList= IN[0]
> searchforList=IN[1]
> 
> test=[]
> 
> for n,s in zip(numberList,searchforList):
> 	temp=[]
> 	if s in n:
> 		temp.append(n.index(s))
> 	else:
> 		pass
> 	test.append(temp)
> 
> 	
> OUT =test


Thank You Fiesta for your effort but still :frowning: cannot get the result I am seeking with the script.

Pls write a simple example of what you need.
Like:

aList[[1,2,3][1,2,3][1,2,3]]
bList[[1][2][3]]

result[] ???

“A” list (0)[1,2,3] (1)[4,5,6] (2)[7,8,9] number in brackets (x) number of sublist
“B” list (0)[2] (2)[6] (3)[0]
return index of B matching A list (only with the same list indexes)
image

image

import clr
clr.AddReference("RevitAPI")
clr.AddReference("ProtoGeometry")
clr.AddReference("RevitNodes")
clr.AddReference("RevitServices")
clr.AddReference('RevitAPIUI') 
clr.AddReference('DSCoreNodes') 
import DSCore
from DSCore import *
import Autodesk
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
import RevitServices
from Autodesk.Revit.UI import TaskDialog
from Autodesk.Revit.DB import *
from Autodesk.DesignScript.Geometry import *

#The inputs to this node will be stored as a list in the IN variables.
numberList= IN[0]
searchforList=IN[1]

result=[]

for nn,s in zip(numberList,searchforList):
	if s in nn:
		result.append(nn.index(s))
	else:
		pass

	
OUT =result

hope this is what you need;)

The script is working fine, just 1 last thing, You forgot the sublists.
image

well…if there is only one item in every sublist…you don’t need sublists…
but here is the script with sublist in the result:
image

1 Like

It seems to work perfectly. I guess I need to get into Python script. Big thanks

Works, need to flatten first list

Works, need to cahnge lacing “==” to longest

I meant flatten your first list (of three items) so that the first sublist (item 1) of List1 is aligned with the first sublist (3 items) or List2. List structure is very important.