Set Site view active

Set Site view active

MarkSanchezSPEC
Advocate Advocate
765 Views
2 Replies
Message 1 of 3

Set Site view active

MarkSanchezSPEC
Advocate
Advocate

Is there a way to set the "Site" view active via the API (see attachment)

 

Using some other view-related posts, this is what I've come up with so far; I can iterate and find the View but how do I set it "active"?

 

            If doc.ActiveView.Name <> "Site" Then
                Using tr As New Transaction(doc, "SetSiteView")
                    tr.Start()
                    For Each v As View In New FilteredElementCollector(doc).OfClass(GetType(View))
                        If v.Name = "Site" Then
                            v.Active = True    'SOMETHING LIKE THIS?
                            Exit For
                        End If
                    Next
                End Using
            End If

 

0 Likes
Accepted solutions (1)
766 Views
2 Replies
Replies (2)
Message 2 of 3

matthew_taylor
Advisor
Advisor
Accepted solution
Hi,
This should do it:
Dim uiDoc as UI.uiDocument = _
new ui.uidocument(doc)
uiDoc.ActiveView=siteView

Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 3 of 3

MarkSanchezSPEC
Advocate
Advocate

UIDocument did the trick. Guess I need to look into the differences between the two "documents", but I think I have some idea.

 

This was my final code:

 

            Dim uiDoc As UIDocument = New UIDocument(doc)
            If uiDoc.ActiveView.Name <> "Site" Then
                For Each v As View In New FilteredElementCollector(doc).OfClass(GetType(View))
                    If v.Name = "Site" Then
                        uiDoc.ActiveView = v
                        Exit For
                    End If
                Next
            End If

Cheers!

 

0 Likes