Get open Sheets (UIViews) even if a View is active

Hello pyRevit Friends :slight_smile:

I have this code to get all sheets that are currently opened as windows in the project.

def OpenSheets():
    outlist = []
    uiviews = uidoc.GetOpenUIViews()
    for uiview in uiviews:
        view = doc.GetElement(uiview.ViewId)
        if view.Category.Name == "Sheets" and view.Name != "None":
            outlist.append(view)
    sorted_elements = sorted(outlist, key=lambda x: x.SheetNumber)
    return sorted_elements

My problem is that i can not get the sheet if a view on this sheet is active. Because uidoc.GetOpenUIViews() will then retrieve the active view and not the sheet.

As far as i know it is not possible to deactivate a view with the Revit API.
Is there any other workaround i can use to get my desired sheet, even if a view is active?

Appreciate any advice :slight_smile:

Kind Regards!

I’m not behind my pc anymore but could there be a solution in finding the sheets on which the views are placed if a view is open.

Don’t know if this will give you the correct set of sheets you want for your script.

1 Like

you may have to check it differently.
AFAIK you don’t have a build in method for that.
But what works is that the tab is not changing name when a view is activated in a sheet:

  • I have sheet 001 opened
  • I activate a view
  • the title in the tab remains the same -Sheet title

so by checking the active view against the tab title you should get there.
reference: Solved: How can I detect activated view on sheet - Autodesk Community

Circumvolated

1 Like

Oh, so MainWindowTitle was what i was looking for. This should work, will be back with results.

Thanks for your replies! :slight_smile:

1 Like

Hmm, I´m struggling to get what i want.

I can get the Title of the Revit Main Window with

import System
print System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle

and yes i can check this title for the string “Sheet”. But this works only for the active view/sheet.

But I can´t find out how to get the title of all open windows/tabs, thats what i would need.

finding the sheets on which the views are placed if a view is open.

This would not work because you can not tell if a view is an open view or an activated view on a sheet.