_Noecho ! _-RunPythonScript ("""Toggles open panels from user specified list. Panels should be docked before closing or they will open floating. Script by Mitch Heynick 110.04.19 Experimental - use with caution...""" import rhinoscriptsyntax as rs import scriptcontext as sc import Rhino, System def PanelList(): a=Rhino.UI.PanelIds.ContextHelp #0 b=Rhino.UI.PanelIds.Display #1 c=Rhino.UI.PanelIds.Environment #2 d=Rhino.UI.PanelIds.GroundPlane #3 e=Rhino.UI.PanelIds.Layers #4 f=Rhino.UI.PanelIds.Libraries #5 g=Rhino.UI.PanelIds.LightManager #6 h=Rhino.UI.PanelIds.Materials #7 i=Rhino.UI.PanelIds.Notes #8 j=Rhino.UI.PanelIds.ObjectProperties #9 k=Rhino.UI.PanelIds.Rendering #10 l=Rhino.UI.PanelIds.Sun #11 m=Rhino.UI.PanelIds.Texture #12 #Grasshopper RCP ID n=rs.coerceguid("b45a29b1-4343-4035-989e-044e8580d9cf") #13 #Named CPlanes ID o=rs.coerceguid("8f23551a-a05b-4a03-a8d5-3e2fc55e4d8a") #14 return[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o] def MyPanels(pl=PanelList()): #edit this list to choose which panels you want from master list above #keep the panels in the order you want the to appear return[pl[2],pl[5],pl[11],pl[10],pl[7],pl[9],pl[4]] def ToggleMyPanels(): panel_ids=MyPanels() panel_ids.reverse() #need to make visible in reverse order docks=[Rhino.UI.Panels.PanelDockBar(panel_id) for panel_id in panel_ids] #check for existence of previous setting if "TogglePanelsVis" in sc.sticky: vis_state=sc.sticky["TogglePanelsVis"] else: #initial test for visibility for panel_id in panel_ids: if Rhino.UI.Panels.IsPanelVisible(panel_id): #at least one panel is visible, hide them all, save setting, exit rs.EnableRedraw(False) for panel_id in panel_ids: Rhino.UI.Panels.ClosePanel(panel_id) sc.sticky["TogglePanelsVis"] = False #all closed return else: continue #if you get to here, there is no panel showing vis_state=False if panel_ids: rs.EnableRedraw(False) if vis_state: #panels are showig, close them for panel_id in panel_ids: Rhino.UI.Panels.ClosePanel(panel_id) else: for i,panel_id in enumerate(panel_ids): #try to re-doc panels where they were if docks[i] != System.Guid.Empty: Rhino.UI.Panels.OpenPanel(docks[i],panel_id,False) else: #panel not docked Rhino.UI.Panels.OpenPanel(panel_id) #invert visibility state and store setting sc.sticky["TogglePanelsVis"] = not vis_state ToggleMyPanels() )