How can I use the API to close open views except the active view?
I can't see how to close a view....
Hi
Not tried or checked in any way the following.
You could check what happens if you delete the view from the project with Document.Delete() method, because view also derives from Element.
var pCurrView = pDoc.ActiveView; pUIDoc.RequestViewChange(pCurrView); var lViews = pUIDoc.GetOpenUIViews(); foreach (var pView in lViews) { if (pView.ViewId != pCurrView.Id) pView.Close(); }
Where pDoc is your Document and pUIDoc is you UIDocument. Keep in mind, you can access your Document via the UIDocument
UIDocument.GetOpenUIViews Method Gets a list of all open view windows in the Revit user interface, not only the ones in UIDocument so it may return views from other documents and it may happen that some of them have the same id as the one you want to close so you may end closing mopre than one view