How to filter and set "Key Parameter"?

Hello,

how do i set a key parameter… i get them via .AsValueString()

import clr
import sys 

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

ODE_GESCHOSSDECKEN = "ODE_Geschossdecken"


#functions
def tolist(x):
    if hasattr(x,'__iter__'): return x
    else: return [x]

#collector
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors)
slabs = tolist(collector.WhereElementIsNotElementType().ToElements())

_fire = [i.LookupParameter(ODE_GESCHOSSDECKEN).AsValueString() for i in slabs]


OUT = slabs, _fire


grafik
grafik

tragely my list remains empty

KR

Andreas

Dropdown selections typically use ElementIds or numeric indicators. You could always try returning the value using each of the return methods or you could return just the parameter and use a node to get the value and check its object type.

1 Like

@Nick_Boyts ,

the LookUp showed me that values are not a “format” Value is stored as Element…

I will check… how to set the “Parameter”

KR

Andreas

AsElement means ElementId. So your best bet in that case is to get the elements (keys) from the key schedule and use that as a kind of lookup. That would depend on how you’re specifying the value to use, but could be name matching, a dictionary, or something similar. Setting a value as an ElementId is the same as any other type. With nodes, that’s the Element object itself. With Python and the API, that’s the ElementId.

1 Like