Change/modify viewports with Grasshopper Python


I am struggling because I can’t find a way to maximize a viewport with scripting via grasshopper python scripting.

What I want to do is select one of the existing viewports in Rhino (for example, Top or Perspective or Right or Front) and maximize it. I found a script online that is similar to what I want to do, but instead of CREATING a new viewport, I want to SELECT one of the existing viewports in Rhino and MAXIMIZE it, not as a floating window:

import Rhino
import System
import rhinoscriptsyntax as rs

if r:
    #Create a new floating view
    newView = Rhino.RhinoDoc.ActiveDoc.Views.Add("TEST", Rhino.Display.DefinedViewportProjection.Perspective, System.Drawing.Rectangle(0, 0, 600, 600), True)
    #Change display mode to "Shaded"
    shaded_id = Rhino.Display.DisplayModeDescription.ShadedId
    display_mode = Rhino.Display.DisplayModeDescription.GetDisplayMode(shaded_id)
    newView.ActiveViewport.DisplayMode = display_mode
    #Maximize viewport
    newView.Maximized = True
    #Zoom extents

Thanks in advance,



1 Like