Hallo dear Community,
to create a custom preflight check, I need to get parameter values. For regular parameters no problem, but if I do the same for parameters in drop-down list it returns “none”, eventhought it’s not none in the Revit Model.
How can I solve this? Thanks in advance.
#shared String parameter → works
addexp = wall.LookupParameter(“Expositionsklasse”).AsString()
print(addexp) #Built in drop-down list parameter-> doesn’t work
addBetDeck = wall.LookupParameter(“Rebar Cover - Exterior Face”).AsString()
print(abbBetDeck)
import os, sys, datetime
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
from Autodesk.Revit.DB.Architecture import *
import time
# pyRevit
from pyrevit import forms, revit, script
# .NET Imports
import clr
clr.AddReference('System')
from System.Collections.Generic import List
# List_example = List[ElementId]()
from Autodesk.Revit.DB import *
import System
doc = __revit__.ActiveUIDocument.Document
time_start = time.time()
# 🏓 get doors
all_elements = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements()
src_element = list(all_elements)[0]
# Create a List of Parmaeter Names
p_names = [p.Definition.Name for p in src_element.Parameters]
# Select Parameter
sel_p_name = forms.SelectFromList.show(p_names, button_name='Select Item')
for el in all_elements:
p = el.LookupParameter(sel_p_name)
if p:
if p.StorageType == StorageType.String:
value = p.AsString()
print('Element[{}] {}: {}'.format(el.Id, sel_p_name, value))
time_end = time.time()
duration = time_end - time_start
print("\n The code took {} seconds to run.".format(duration))
# ✅END