Specify View via code block or python

In the graph below, I´d like to (i do need to) replace the ‘Views’ node by a code block or Python script. The reason is that it can change itself when the user creates or deletes some view.

That Python script in the graph reads the Schedule (I didn´t find the author or post now and don´t remember, unfurtunately) - and i will merge about 10schedules.

Any idea about a way replace it? Maybe inside the python code?

I did some searching around and found this post a while ago, this should help give an understanding of the idea to use.

I’ve also inputted that code into python and played around with it to achieve what you are looking for.

# Load the Python Standard and DesignScript Libraries
import sys
import clr
from Autodesk.DesignScript.Geometry import *

import Revit

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

import Autodesk
from Autodesk.Revit.DB import *

elements = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views).WhereElementIsNotElementType().ToElements()

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:
	return passed

# The inputs to this node will be stored as a list in the IN variables.
NameSrch = IN[0]

FoundViews = filter_list(elements, NameSrch)

# Assign your output to the OUT variable.
OUT = FoundViews

Hope this helps!

1 Like