Using the Element.Name property you can do this quite easily. The following expects IN[0] to be a list of elements. You can also greatly reduce the redundancy in your script by defining a custom function:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
def filter_list(elements, search_str):
"""Given a list of Views, returns only those which
contain a given string in their name"""
passed = []
for element in elements:
name = element.Name
if search_str in name:
passed.append(element)
return passed
views = [UnwrapElement(view) for view in IN[0] if view is not None]
nwc = filter_list(views, 'NWC')
elec = filter_list(views, 'ELEC')
OUT = nwc, elec
views.dyn (5.1 KB)
This could also be easily modified to accept a list of strings to test (e.g. ["NWC", "ARCH", "STRC"...]) since you’re combining all of the lists anyway.