"Persistent Data" with Python


I have a python components that asks for a user input with rhinoscript listbox function.

I want to make this question to users only one time, its about the projectID, and dont bother them again with this question.

My problem comes that each time that GH runs/refresh, the same prompt pops up again and again. If a use a variable in the scope of the python component in order to check that prompt was made before, it happens that it is being overwritten on each GH refresh.

I would like to know if it possible to store data at document level, so I somehow put a flag on it to know in order to know if a prompt about the project ID was ever made.

any help would be appreciated

well i guess that scripcontext´s sticky dictionary can be a solution to my problem. Need to check if data is still there after a computer restart ( can´t do it now…)

anyway, Iam still interested in your opinion

What if you defined the project id as one of the inputs to your component and then reported an error when this was not set? That way saving of the data would automatically be handled for you.

Hi steve,
i can see your idea as method to get sure that “projectID” is always set, but still cant see how would i would get sure that data is going to be there the next time i open the document…oh, i see, “projectID” could be “hardcoded” as an input for example with Panel component, right?

uhmm… still not satisfied with that solution. We want to be sure that ProjectID (a list of ID´s is queried from a database and are presented to the user for choosing one) is asked only one time in the lifecycle of the document, avoiding the possibility of an accidental ID change anytime in the future. So my idea was that there is a python component wich launch the prompt only one time, or at least until an ID is passed in, and then store this data “forever”.

Is it there any way to store data, kinda custom user attribute, associated with a GH document? I have overviewed GH SDK but I haven’t found anything…



if you can create a python component in GH, use eiter




to store the ID. Both get saved with the document so you can check the value before. Both methods are available in RhinoCommon as well. You might look for the StringTable.


Thank you very much Clement, this is what I was looking for!

In order to store persistent Data in GH document itself (instead of Rhino Document), I found this other approach in GH forum.

Thanks again!

By the way, sticky dictionary was not a proper solution to my problem, as It doesn’t persist after a rhino restart.