[Python] Adjust size of existing, active floating viewport


I have been unable to find the correct python call to adjust the size of an existing, active floating viewport. Essentially, I need the equivalent of:
rhinoscriptsyntax.Command ("-viewportProperties _Size 400 200 Enter" )
… but without the Command() call

Here’s what I have, which appears to change the view buffer size, but not the floating window size:

activeViewport = doc.Views.ActiveView.ActiveViewport
dims = System.Drawing.Size( 400, 200 )
activeViewport.Size = dims

Any help would be greatly appreciated.

For others, a working solution:

import scriptcontext
import System

# 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
            dims = System.Drawing.Size( 400, 200 )
            view.Size = dims

if __name__ == "__main__":

Focus_Test.3dm (63.7 KB)

1 Like