Get referring view using API

Get referring view using API

anvdi
Explorer Explorer
465 Views
4 Replies
Message 1 of 5

Get referring view using API

anvdi
Explorer
Explorer

Hi,

 

I am having some trouble when using API to find the referring view for the selected view

 

Does anyone have any ideas for this issue?

0 Likes
466 Views
4 Replies
Replies (4)
Message 2 of 5

dfoth
Advocate
Advocate

View Reference isn't available in the API, yet. I don't know why. I need it as well. 

Message 3 of 5

Sean_Page
Collaborator
Collaborator

This is possible, you have to use the Viewers category to collect them.

 

#Sean Page, 2024
import clr

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

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument

#Select a View (This test is an Exterior Elevation
check = UnwrapElement(IN[0])
res = []

#Collect All Views
allViews = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views).WhereElementIsNotElementType()
for view in allViews:
    #Check to make sure it isn't a View Template
    if not view.IsTemplate:
        #Collect Viewers that are within the Views Collector
        viewers = FilteredElementCollector(doc, view.Id).OfCategory(BuiltInCategory.OST_Viewers).WhereElementIsNotElementType()
        for viewer in viewers:
            #Check the View and Viewer name to find the matching ones
            if viewer.Name == check.Name and viewer.Name != view.Name:
                res.append(f'{view.Name} - {view.get_Parameter(BuiltInParameter.VIEWPORT_DETAIL_NUMBER).AsString()}/{view.get_Parameter(BuiltInParameter.VIEWPORT_SHEET_NUMBER).AsString()}')

OUT = res

 

List of Views the Elevation Shows up in and the Detail / Sheet of those Views if placed.

Sean_Page_0-1733971301898.png

 

 

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 4 of 5

dfoth
Advocate
Advocate

@Sean_Page 
You are correct that we can get the information, but we cannot place a text type of View Reference in Revit using dynamo. By text type I mean "6/A201", not a callout or section view reference, just "smart" text. 
But if I'm incorrect, please share any solutions you may have as it would be greatly appreciated.  We've used dummy View Reference families where the text is actually just "dumb" text and then fed the dynamo collected information into the dummy view reference but that can be risky on big projects.

Message 5 of 5

Sean_Page
Collaborator
Collaborator

Thanks for the clarification @dfoth, based on the image provided I thought we were just trying to get a list. Looks like this is also a post about it, and still does not seem possible as you noted as well.

 

https://forums.autodesk.com/t5/revit-api-forum/placing-a-view-reference/m-p/11722319/highlight/true#...

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect