Toggle all panels script

I made a python script to toggle all currently open panels to mimic the behavior of Adobe products when you press the Tab key.

I found that trying to this using the rhino commands resulted in the panels reappearing in the wrong order and it would take a while with noticeable flickering compared to right-clicking and selecting close, which is instant.

This is faster and panels don’t flicker, but it still doesn’t guarantee that the tab that had focus will retain its focus when reopened. Maybe someone can suggest how to address that remaining issue.

import scriptcontext as SC
import Rhino

A = 0
currentlyOpen = 0

if (SC.sticky.has_key("panelsToToggle")):
    A = SC.sticky["panelsToToggle"]
    currentlyOpen = Rhino.UI.Panels.GetOpenPanelIds()
if currentlyOpen:
    SC.sticky["panelsToToggle"] = currentlyOpen     
    for i in currentlyOpen:
if not currentlyOpen:
    if A:
        for i in A:

@arch, no idea about the focus problem. I´ve found that the panel order is not preserved when panels are re-opened. (happens if multiple panels are stacked in a row beside each other). btw. you might replace:


with below code so you do only delete your own sticky key and keep others untouched:



thanks for that, I wasn’t sure how to accomplish it.

unfortunately the script sill doesn’t restore panels to their original position upon reopening; everything goes to the same side of the screen.maybe that is possible to fix somehow?


i first asumed this may have to do with the order the panel ids are stored in the sticky dictionary, but the order seems to be preserved. So i do not know a way how to prevent it. It looks like RhinoCommon has a method to open a panel as a sibling of another using:

Rhino.UI.Panels.OpenPanelAsSibling(panelId, existingSiblingId)

but i see nothing to find out SiblingIds before closing opened panels.

@dale would this be a route to go to preserve panel positions once re-opened after closing them ?


I honestly don’t know how I would do this (with Python or anything else). There is a lot to getting docking stuff to show up where its supposed to. Just closing and reopening panels isn’t enough, that’s for sure.

Thank Dale.

@arch, since there is no way to do this, you might take a look at using _-Fullscreen instead. It will hide toolbars too, but otherwise makes the same as your script if you set everything to No except these:

ShowCommand=Yes ShowStatus=Yes ShowMenu=Yes ShowTitle=Yes


fullscreen hides the toolbars though

Yes. Maybe the _FullScreen command needs an option to keep them visible.


That should definitely be an option for fullscreen, but what if I have 3 or 4 instances of Rhino open, along with grasshopper for each one? I need to manage layers/properties/display options frequently, but not constantly. A nice toggle would be ideal without having to go fullscreen.

So I’ve found that Rhino does have the behavior that I want, but I still can’t figure out how to replicate it in a quick keyboard shortcut or button.

When you right click on the layers panel and click “close”, or you just close it with the “X” on a floating panel, and then, you right click on the layers control down at the bottom status bar, the layers panel and all it’s “siblings” will reopen in the same order and position they were before. This also happens near instantaneously.

Is there some method to this is RhinoCommon?

Hi @arch,

You mean something like this?

import Rhino
layer_id = Rhino.UI.PanelIds.Layers

– Dale

Hi Dale,

It almost works… If I close manually then run the OpenPanel, it’ll open everything in that window together in the same order. If I use ClosePanel, it closes only one at a time