If you input a single document that’ll work (I think). It’s not working because you haven’t set up another loop to work through each document in the list and run the FilteredElementCollector on each.
Currently you aren’t iterating across each document, which you would need to do in order to collect view templates in that scenario. I’d suggest using a custom node if you can get away with it and using list levels, otherwise you could try something like this…
# Function to ensure input is a list and unwrapped
def uwlist(input):
result = input if isinstance(input, list) else [input]
return UnwrapElement(result)
# Make sure the input is a list of documents
docList = uwlist(IN[0])
# Empty list for template lists
templatesList = []
# For each document...
for doc in docList:
# Get all views
views = FilteredElementCollector(doc).OfClass(View)
# Make a list
templates = []
# For each view, if it is a template, add to the list
for v in views:
if v.IsTemplate:
templates.append(v)
# Add the list to the overall list
templatesList.append(templates)
# Output to Dynamo
OUT = templatesList
Here is an example of using custom nodes from Crumple to get all view templates for all link instances: