Hi All,
i’m trying to return the next element in sublists for the later use in calculations.
My input is a Nested List like this one:
In my Python-Script i’m searching for a certain element by parameter-value ( in this case it is the element with the ID 7325678)
Once the element is found i want to return the next element. I used the enumerate method to create a tuple and use the index to return the next element. This is working fine.
My problem being that when i try to define this as a function it is only returning the next item from the first sublist for both sublist. (see picture)
I can’t figure out why it is not working and would be thankful if someone might have an answer.
Greetings, Reinhard.
# Phython-Standard- und DesignScript-Bibliotheken laden
import sys
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
# Input aus der IN[]-Variable in die Elementliste schreiben
Elementlist = []
Testlist = []
if isinstance(IN[0],list):
Elementlist = UnwrapElement(IN[0])
else:
Elementlist = [UnwrapElement(IN[0])]
# Code unterhalb dieser Linie platzieren
def Methode(element):
Methode = element.LookupParameter("Berechnungsmethode").AsString()
return Methode
def Test(element):
List = []
for index, inner in enumerate(Elementlist):
for idx, element in enumerate(inner):
if Methode(element) == "Verzweigung":
List.append(inner [idx+1])
return List
for i in Elementlist:
Testlist.append(Test(i))
List = []
for index, inner in enumerate(Elementlist):
for idx, element in enumerate(inner):
if Methode(element) == "Verzweigung":
List.append(inner [idx+1])
OUT = List, Testlist