Use dynamo to find all "Referring Views" - trying to reference all annotation symbols that generates a particular view

When a view is active you can right-click revit and get a list of the all the views where that view’s annotation symbol is visible.

For example, if that view is created by an elevation tag, you can use “Referring Views” selection to find all the other views where that elevation tag is shown.

What is the dynamo node equivalent of “find referring views”? I would like to use dynamo to hide the annotation symbol of a particular view. (thereby changing the reference detail / sheet) in its parameters.

Thanks

I couldn’t find anything on this and I was curious enough to try it in Python… seems it might be useful enough for me at some point, too :slight_smile: I’m using archi-lab and Rhythm to collect the views that are on sheets given that the reference detail / sheet aspect of your inquiry pertains to those views


image

Python script:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

views = UnwrapElement(IN[0])
name = IN[1]

def getRefs(sheetviews, vName):
	refViews = []
	for view in sheetviews:
		viewColl = FilteredElementCollector(doc, view.Id).OfCategory(BuiltInCategory.OST_Viewers).ToElements()
		for viewer in viewColl:
			if viewer.Name == vName:
				refViews.append(view)
	return refViews
	
OUT = getRefs(views, name)

Looks to be working :slight_smile: hope this helps

10 Likes

This python script also works for tags that are referencing existing views, which is very convenient.

My intention is to turn off reference tags (elevation marks / section marks) until my referencing detail number for a specific view is correct. For referencing details, Revit uses the first detail it comes across in the sheet order. The first detail is not necessarily the one that should be used for the referencing detail number / sheet. Sometimes these referencing details are just on haphazardly. I will ask the user which detail they intend to use as the referencing detail and turn all other reference tags off (hide).

When I run this on a large file, Revit starts to “generate” each sheet. Would this be quicker by creating a list of views in the project?

Yes if you have specific views that you wish to target, it would certainly be faster to process a smaller, filtered list of views. But you would want to be sure to filter in a way that will not potentially exclude referring views

1 Like

It seems to take Revit much longer to go through the sheets , than it takes Revit to make a list of views and apply the python script. I will make a list of views in the project and start filtering (trying to avoid revit going through each sheet – i have 400 sheets in this project…lol).

Just wondering. Since the referring views list already exist in Revit and can be called up pretty quickly, can Python be used to reference that list directly as opposed to doing the comparison in Dynamo?

Sorry, I couldn’t find anything in the API docs nor from searching elsewhere; if this is a retrievable list I’m unaware of it.

1 Like

Instead of appending the view here:

		if viewer.Name == vName:
			refViews.append(view)

What if a true/false list was created instead? I imagine generating a true false list is faster than appending said view.

Than an IN/Out filter could be used to find referring views.

The lag time is more likely in this portion where the script is iterating through all of your views and collecting the type of elements you’re after in each of those views:

	for view in sheetviews:
		viewColl = FilteredElementCollector(doc, view.Id).OfCategory(BuiltInCategory.OST_Viewers).ToElements() 

Appending the view element to the list is just moving already collected data around, so appending booleans wouldn’t improve speed, but if you wanted the script to output booleans you’d modify the area of code you pasted like so:

			if viewer.Name == vName:
				refViews.append(True)
			else:
				refViews.append(False)

Fortunately with this script as it is, each consecutive run after the first one will be much quicker because all of the views and elements are already collected, but it sounds as if you might have been developing this to be a Dynamo Player script, so that doesn’t benefit you with speed.

I racked my brain on how to achieve what you’re after and can’t think of a method that would be 100% effective without requiring Dynamo to be searching through a collection of elements, so am unsure of a faster solution.

A possible direction to take would be to hide the referencing elements out of the incorrect views deductively… I’m not sure this would be the best method, but might be worth trying for your use case:
referencing%20viewer

The Python script is giving you the element (call out, section, etc. ) that appears in the view that you dont wan’t as the referencing view, so the element that you’re looking to hide… this is the script:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

views = []
if isinstance(IN[0],list):
	for i in IN[0]:
		views.append(UnwrapElement(i))
else: 
	views.append(UnwrapElement(IN[0]))
	
name = IN[1]

def getRefs(sheetviews, vName):
	refViews = []
	for view in sheetviews:
		viewColl = FilteredElementCollector(doc, view.Id).OfCategory(BuiltInCategory.OST_Viewers).ToElements()
		for viewer in viewColl:
			if viewer.Name == vName:
				refViews.append(viewer)
	return refViews
	
OUT = getRefs(views, name)

Again, I don’t think this is the best method, as you would have to be hiding in view by each view until you see the correct referencing sheet / detail populating your parameters, which could probably get messy to keep track of.

1 Like

Yes. Thanks for the correction. The time consuming part (for larger projects) is iterating through all of the views and collecting the type of elements in each of those views. I did find that collecting views directly may be less time consuming since it does not process each sheet.

Hiding the element (call out, section) in the view may be a good script while people are creating each view and placing them on the sheet. Another direction may be to do this less repetitively (before milestones) as an excel data round-trip for all views:

Steps:

  1. Let the script finding reference markers run for several hours and produce an excel sheet showing views versus their reference tags.

  2. Update the excel sheet to select which reference view from the list should be THE referring detail.

  3. Dynamo reads this excel file and hides or shows view markers according to your selection in excel.

A process like this would not need to be done frequently. Sort of like doing a massive spell-check, but choosing the correct word in excel.

I have successfully run your Deductive Definition and it is much faster. Can this definition be looped to keep running until it finds a specific detail number?

I would like the user to select a elevation mark (mark number and what sheet it sits on), and then the definition could keep hiding views until it hits the elevation mark that matches it.

Technically this could be done in Python using a while loop, but to prevent the script from hanging in the case that the user puts a detail number that isn’t a referring view, I’m afraid it would have to go through the process of first finding the referring views, and ultimately would take just as long as the others

Couldnt the risk of hanging be mitigated by asking the user to select the targeted referring marker with a mouse selection.

Therefore the chances of matching the marker tag and stopping the loop at the right time are much higher than just solely inputting a number.

Also, there could be code to tell the loop to break after a set number of marks are hidden.

*sorry for types I was on phone

1 Like

Come to think of it, If the user selects a reference maker on a particular sheet that is not the current referring sheet, then the while loop can continue through a whole sheet and then stop (a logical stopping point for the while loop?). This way the definition can eliminate sheets deductively.

1 Like

I am afraid you are correct.

There is no way to keep dynamo looping this without getting into different roadblocks.

Is there a way to do this in 2021? What Add-in packages are required? Some of the modules in Rhythm don’t exist anymore.

Better to start a new thread (feel free to reference this one).

New thread: Referencing Sheet - Manipulating / Controlling - Revit - Dynamo (dynamobim.com)