Hi all, i think maybe is a silly question but i’m right know knocked about that.
I want to check every single index value of a list (4 in that case) with another list and if it match put another value associate with the list (3 in that case)
Right know i get a list with the values but the code check all the elements in list 4 firs with first index of list 3 and then continue.
Can you help me with a little test?
This is what i’m getting right now.

I figured out making a dictionary inside the code.
Thx
1 Like
@Sergio.Ramirez2 Could you post the code that solves the issue?
Sure, this is a bit part of a graph to place Fire Dampers in RF linked walls, by type using at the final MEPover node
Given a type of fire dampers and a size of ducts, first create all the FD by type if not exist already and then match every duct size with their FD to avoid unwanted reductions.
This is a first aproach, now i want to work with list logics because all the FD manufacters dont have the same duct size we use…
Example:
If the FD manufacter is 300x300 and 400x400 and you have a duct 350x350, put the next FD (400x400)
The other step is to work depending of the Airflow and dBa in this point.
import clr
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import System
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
filter = IN[0]
if isinstance(IN[1], list):
ducts = UnwrapElement(IN[1])
else:
ducts = [UnwrapElement(IN[1])]
elementTypes = []
elementFamNam = []
elementTypSize = []
ductMatch = []
listF = []
DuctHeight = []
DuctWidth = []
for duct in ducts:
ductheight = duct.get_Parameter(BuiltInParameter.RBS_CURVE_HEIGHT_PARAM)
ductwidth = duct.get_Parameter(BuiltInParameter.RBS_CURVE_WIDTH_PARAM)
DuctWidth.append(ductwidth.AsValueString())
DuctHeight.append(ductheight.AsValueString())
for duh,duw in zip(DuctHeight, DuctWidth):
ductsize = duw + "x" + duh
ductMatch.append(ductsize)
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_DuctAccessory).WhereElementIsElementType().ToElements()
for d in collector:
if d.FamilyName == filter:
#dSize = d.get_Parameter(BuiltInParameter.RBS_CALCULATED_SIZE)
elementFamNam.append(d.Family.Name)
elementTypes.append(d)
#Buscamos el parametro por el que filtrar
value = d.LookupParameter('Type Comments').AsString()
elementTypSize.append(value)
else:
pass
"""for dS in ductMatch:
if dS in elementTypSize:
pass
else:
d = ("Falta añadir el tipo de compuerta" + " " + dS)"""
for index in range(0,len(ductMatch)):
if ductMatch[index] == value:
pass
else:
d = False
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
listSize = tolist(elementTypSize)
listTypes = tolist(elementTypes)
dict1 = dict(zip(listSize,listTypes))
Valores = [dict1.get(sv, d) for sv in ductMatch]
listM = []
for f in Valores:
if f == d:
list2.append(f)
OUT = collector, elementTypes, elementFamNam, elementTypSize, ductMatch, Valores, listM
Sorry a little mistake copying, in line 92 is “listM”