Search code examples
c#revit-api

How to close an open view, however it is active view or not?(Revit 2017, 2018, 2019)


I'm trying to build an addin function which can batch open or close views. But I cannot find the API methods in Revit API manual. Anyone knows how to open or close Revit view programmatically?


Solution

  • You can use the UIDocument.ActiveView property to switch views. This will activate one view and thus close any other.

    You can use the Document.Close method to close the last view of a document.

    That should cover most cases.

    If you are thinking of doing anything else, think twice, since it is not completely supported by the Revit API, and you might be working against the system, not with it.