Created
October 14, 2016 13:59
-
-
Save AndersDeleuran/09f8af66c29e96bd35440fa8276b0b5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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