Skip to content

Instantly share code, notes, and snippets.

@AndersDeleuran
Created October 14, 2016 13:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndersDeleuran/09f8af66c29e96bd35440fa8276b0b5a to your computer and use it in GitHub Desktop.
Save AndersDeleuran/09f8af66c29e96bd35440fa8276b0b5a to your computer and use it in GitHub Desktop.
from scriptcontext import sticky as st
import Rhino as rc
def customDisplay(toggle,component):
""" Make a custom display which is unique to the component and lives in sticky """
# Make unique name and custom display
displayGuid = "customDisplay_" + str(component.InstanceGuid)
if displayGuid not in st:
st[displayGuid] = rc.Display.CustomDisplay(True)
# Clear display each time component runs
st[displayGuid].Clear()
# Return the display or get rid of it
if toggle:
return st[displayGuid]
else:
st[displayGuid].Dispose()
del st[displayGuid]
return None
def killCustomDisplays():
""" Clear any custom displays living in the Python sticky dictionary """
for k,v in st.items():
if type(v) is rc.Display.CustomDisplay:
v.Dispose()
del st[k]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment