Is there any way in Grasshopper to uniquely identify parameters or their data? With geometry referenced from Rhino, there is a unique Guid, but what about with Grasshopper made objects?
For example, I have a custom component that accepts one or more curve parameters. Let’s assume that I connect 3 curves created by various ways with vanilla Grasshopper components. If one of the curves changes, I would like to be able to tell which of the 3 curves changed.
Try this code in a python component with output parameter U
. It remembers the last timestamp of the input parameters and checks for updates.
import scriptcontext as sc
unique_string = str(ghenv.Component.Attributes.InstanceGuid)
KEY = unique_string + "_KEY_PREV"
new_times = [param.ProcessorTime.ToString() for param in ghenv.Component.Params.Input]
if sc.sticky.has_key(KEY):
U = [old != new for old, new in zip(sc.sticky[KEY], new_times)]
else:
U = [True for new in new_times]
sc.sticky[KEY] = new_times