improved thanks to post by @Kulkul, although there may have been a simpler way possibly…
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
clr.AddReference('DSCoreNodes')
import DSCore
doc = DocumentManager.Instance.CurrentDBDocument
fec = FilteredElementCollector
elem_types = []
numtypes = []
elem_names = []
clazz = IN[0]
#clazz = ('CeilingType' , 'FillPatternElement' , 'FilledRegionType',
#'FloorType', 'HandRailType' , 'RailingType' , 'RoofType' , 'StairsType',
#'TopRailType' , 'WallType')
for claz in clazz :
elem_type = fec(doc).OfClass(eval(claz)).ToElements()
elem_types.append(elem_type)
num_types = 0
for elems in elem_type :
elem_name = Element.Name.__get__(elems)
elem_names.append(elem_name)
num_types += 1
numtypes.append(num_types)
def list_chop (chop_list, chop_lengths) :
# 'Kulkul https://forum.dynamobim.com/t/list-chop-problem/21357/7
chopped_list = []
sub_dex = 0 # 'inital index of item in sub list
sub_length = 0 # 'initial sub list length
while sub_dex < len(chop_list) and sub_length < len(chop_lengths) :
sublist = []
for i in range(int(chop_lengths[sub_length])) :
if sub_dex < len(chop_list) :
sublist.append(chop_list[sub_dex])
sub_dex += 1
else :
break
chopped_list.append(sublist)
sub_length += 1
return chopped_list
chopped_names = list_chop(elem_names,numtypes)
OUT = elem_types, chopped_names