scriptcontext.sticky
-
scriptcontext.sticky
-
A persistent dictionary in Grasshopper's Python environment that maintains values between script runs
-
Similar to Python's
globals() but persists data even after script completion
-
Useful for:
- Sharing data between different scripts
- Storing configuration settings
- Caching computed values
- Maintaining state between script executions
-
Values stored in sticky dictionary remain until:
- Rhino is closed
- Explicitly removed using
del sc.sticky["key"]
-
Example
import scriptsyntax as sc
def foo():
print("bar")
sc.sticky["foo"] = foo
import scriptsyntax as sc
foo = sc.sticky["foo"]
foo()
>>> bar
Example of how to use scriptsyntax.sticky