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.
I think you just need to flatten your first list. The list structure should be one item per sublist.
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
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 ) 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 Wanted to simplify it by adding a project
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
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)
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.
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:
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