Wish: disable Rhino geometry preview

This is a ghpython example that hides/shows geometry. Similar to above examples, it’s dependent on referencing geometry into a geo parameter. If no geometry is referenced, it hides/shows all geometry in the Rhino Doc.
GHPY_HideShowObjs
GHPY_HideShowObjs.gh (5.8 KB)
unoptimized code below:

"""Show/Hide Objects.
   Inputs:
       Show: Boolean.  Show/Hide Objects in Rhino Document
       objs: Geo.  Optional.  Referenced Geometry to Show/Hide.  If ommitted, all geo will be shown/hidden."""

__author__ = "chanley"
__version__ = "2019.02.04"

import Rhino

def HideAllVisible():
   settings = Rhino.DocObjects.ObjectEnumeratorSettings()
   settings.VisibleFilter = True
   AllObjs = [obj for obj in Rhino.RhinoDoc.ActiveDoc.Objects.GetObjectList(settings)]
   for obj in AllObjs: 
       Rhino.RhinoDoc.ActiveDoc.Objects.Hide(obj, True)

def ShowAllHidden():
   settings = Rhino.DocObjects.ObjectEnumeratorSettings()
   settings.HiddenObjects = True
   AllObjs = [obj for obj in Rhino.RhinoDoc.ActiveDoc.Objects.GetObjectList(settings)]
   for obj in AllObjs: 
       Rhino.RhinoDoc.ActiveDoc.Objects.Show(obj, True)

def HideRefGeo():
   for id in objs:
       Rhino.RhinoDoc.ActiveDoc.Objects.Hide(id, True)
      
def ShowRefGeo():
   for id in objs:
       Rhino.RhinoDoc.ActiveDoc.Objects.Show(id, True)

if Show == False and len(objs) == 0:
   HideAllVisible()
   ghenv.Component.Message = "Hide All"
elif Show == True and len(objs) == 0:
   ShowAllHidden()
   ghenv.Component.Message = "Show All"
elif Show == False and len(objs) != 0:
   HideRefGeo()
   ghenv.Component.Message = "Hide Ref"
else:
   ShowRefGeo()
   ghenv.Component.Message = "Show Ref"

A nice addition, as mentioned above, would be to ping the ghdoc, get the parameters with referenced geo, then get the GUID of the Rhino Geometry from those parameters.

3 Likes