Find views and sheets that show a specific element

… and of curse Revit enters into a long loop that we cannot wait for (it looks like it’s regenerating every view in the project… not good), and we have to quit the application.

Quite amazing how still there is no way to interrupt a Dynamo script: it’s almost 2023 guys…

But thank you for the community inputs, you guys are great.


Hi guys
I see this is an old post, but you can write the script more efficiently. FilterElementCollector has more filtering options with which you can narrow down the selection and you don’t have to iterate through all the elements.

But it will have its limitations:
1.) FilterElementCollector finds only visible elements in the view
2). FilterElementCollector also selects elements that may not be visible but are actually on the view, which is caused by the view range setting

It would be easiest to narrow down the selection for filtered views, for example using the view type (Elevation, CeilingPlan, etc.), name or sorting parameter in the project browser.

I’m saving it here as a reminder to write it more efficiently.

Is this a node or a Pyton command?

thank you

Thank you Hamish,
seems it could help in this thread’s topic, but python methods are above and beyond what I can reasonably manage… :frowning:

For all in this thread, I made a Dynam script, which uses the node “all elements of category in view” at its core, to produce the wanted result, namely, it finds all sheets and views where a selected element is visible.

The node seems to be forcing the regeneration of all views fed to it, which I think it is equivalent to opening every view and looking for the element.

I setup the script to screen sheets and also allow te user to reduce the number of sheets to run tests and limit the run time.

Then the script exports the sheet and view found onto an Excel table.

This works with the Player.

I hope it helps someone.

try this.

The script narrows the selection to only the category of the selected element.
Searches in BuiltInCategory.OST_Views and BuiltInCategory.OST_Sheets view category

If you don’t need both, just remove one and the script will run even faster.

import clr,System
import Revit

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

# Import RevitAPI
from Autodesk.Revit.DB import *

from System import Array
from System.Collections.Generic import *

element = UnwrapElement(IN[0])
elementId = element.Id
elemCatName = element.Category.Name

#Get element BuiltInCategory
bic = System.Enum.GetValues(BuiltInCategory) 
cats, bics = [], []
for i in bic:
        cat = Revit.Elements.Category.ById(ElementId(i).IntegerValue)
for i, b in zip(cats, bics):
    if elemCatName == str(i): 
        ost = b 

#Filter View
cat_list = [BuiltInCategory.OST_Views, BuiltInCategory.OST_Sheets]
typed_list = List[BuiltInCategory](cat_list)
filter = ElementMulticategoryFilter(typed_list)
views = FilteredElementCollector(doc).WherePasses(filter).WhereElementIsNotElementType().ToElements()

output = list()

for v in views:

	if v.IsTemplate:
	elementsCol = FilteredElementCollector(doc,v.Id).OfCategory(ost).WhereElementIsNotElementType().ToElementIds()
	if elementId in elementsCol:

OUT = output

ok I tested it on a large project and it’s quite overkill for Revit… :sweat_smile: :grinning: