# Back Referencing Views - Looking for existing script

**URL:** <https://forum.dynamobim.com/t/back-referencing-views-looking-for-existing-script/19768>\
**Category:** Revit\
**Tags:** revit, dynamo\
**Created:** [March 7, 2018, 7:14pm UTC](https://forum.dynamobim.com/t/back-referencing-views-looking-for-existing-script/19768 "2018-03-07T19:14:59Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![awilliams](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/awilliams/32/114496_2.png) [@awilliams](https://forum.dynamobim.com/u/awilliams)\
**Post date:** [March 8, 2018, 8:30pm UTC](https://forum.dynamobim.com/t/back-referencing-views-looking-for-existing-script/19768/19 "2018-03-08T20:30:12Z")

</div>

@rdeardorff I took a quick pass at it and this (messy) modified script seems to work:

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

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

doc = DocumentManager.Instance.CurrentDBDocument

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

refviews = []

def getRefs(sheetviews, refdview):
	refViews = []
	for view in sheetviews:
		viewerColl = FilteredElementCollector(doc, view.Id).OfCategory(BuiltInCategory.OST_Viewers).ToElements()
		for viewer in viewerColl:
			if viewer.Name == refdview.Name:
				refViews.append(view)
		refColl = FilteredElementCollector(doc, view.Id).OfCategory(BuiltInCategory.OST_ReferenceViewer).ToElements()
		for refviewer in refColl:
			if refviewer.LookupParameter("Target view").AsElementId() == refdview.Id:
				refViews.append(view)
	return refViews

for view in views:
	refviews.append(getRefs(sheetViews,view))
	
OUT = refviews 

```

Note the changes that need to be made to the graph; the Python script now needs the view elements, and not their names, and there are some level changes on the nodes after the Python script:

 ![set%20referring%20view%20parameter](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/4/242ac35d23653b031e6ad74bf8df8c9a4560c66c.png)  
edit: added flatten node after List.FilterByBoolMask

---

_[View the full topic](https://forum.dynamobim.com/t/back-referencing-views-looking-for-existing-script/19768)._
