[Python] Make Rhino View have focus

Hi All,

Given a Rhino View object, how do I make it the focus in the GUI? Specifically, my goal is to give focus to the first floating window in the project.

views = scriptcontext.doc.Views.GetViewList( True, False )
        for view in views:
            if( view.Floating == True ):
                # MAKE THE FOCUS
                print "found floating: ", view.MainViewport.Name

Any help would be greatly appreciated

Hi Ivo,

does this work for you:

views = scriptcontext.doc.Views.GetViewList( True, False )
for view in views:
    if( view.Floating == True ):
        scriptcontext.doc.Views.ActiveView = view
        print "found floating: ", view.MainViewport.Name

-Willem

1 Like

Thank you, Willem.
Here’s a working example for others:

    import scriptcontext

    # Open "Focus_Test.3dm" prior to running this script

    def FocusFloating():
        views = scriptcontext.doc.Views.GetViewList( True, False )
        for view in views:
            if( view.Floating == True ):
                scriptcontext.doc.Views.ActiveView = view
                print view.MainViewport.Name, "should now be the active/focused upon viewport"


    if __name__ == "__main__":
        FocusFloating()

Focus_Test.3dm (63.7 KB)

1 Like