Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

close open views

5 REPLIES 5
Reply
Message 1 of 6
russ.green
2931 Views, 5 Replies

close open views

How can I use the API to close open views except the active view?  

 

I can't see how to close a view....

Russ Green
5 REPLIES 5
Message 2 of 6
russ.green
in reply to: russ.green

or at least just check if a view is open and not active....

Russ Green
Message 3 of 6
ollikat
in reply to: russ.green

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.

Message 4 of 6
russ.green
in reply to: russ.green

you can;t delete an open view.  never mind!

Russ Green
Message 5 of 6
GOverfield
in reply to: russ.green

 

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

Message 6 of 6
Andekan
in reply to: russ.green

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community