Get open Revit Windows (UIViews)

Hello Dynamo Friends :slight_smile:

I would like to know if there is a method to get the sheets that are currently open in the project.

Happy about any advice!
Kind regards

Don’t you mean Windows?

image

If so, not that i know of, but my best bet would be Rhythm.

If not, be more clear.

Edit.
No, Rhythm doesn’t have something you are looking for.

1 Like

Hi @gerhard.p ,

You can retrieve this in Python with GetOpenUIViews()

import clr
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

OUT = []

uiviews = uidoc.GetOpenUIViews()
for uiview in uiviews:
    OUT.append(doc.GetElement(uiview.ViewId).ToDSType(True))

4 Likes

There’s a core node for the active view, but if you want all open views then I believe you’d have to go the python route.

1 Like

Amazing! That will improve a lot of my scripts because everytime i want a user to select a sheet i want to list the opened sheets first :slight_smile:

Thanks Dan!

Out of curiosity.
Why do you want that (with Dynamo)?

For placing views on sheets.
I have this script that lets you move or duplicate views to another sheet.
You have to select the target sheet from a dropdown of 100-200 sheets.

Usually we have this sheets already open, so i want to put the open sheets on first place of the list of sheets for the dropdown.

I had to change the code to make it work in Revit 2022 @Daan, had to remove ToDSType:

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

import System

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

OUT = []

uiviews = uidoc.GetOpenUIViews()
for uiview in uiviews:
    OUT.append(doc.GetElement(uiview.ViewId))

Here is the graph for adding the open sheets to the start of my sheet list:

1 Like

Bonus question, would it also be possible to get the open windows of all open documents, not just from the active document?
Don´t know a use for that now, but maybe in the future…

documents = uiapp.Application.Documents

2 Likes

I found an interesting “issue” when getting open windows, or in my case when i want to get open sheets.
If a sheet is open and a view is active on the sheet, the python code will get the view and not the sheet.

Thats a problem for me because i can´t tell if a view is opened as a window or if a view is active on a sheet.

Here you can see i get a view insted of the second sheet: