Revit/Dynamo "sticky" variables with python

I asked this in the Revit API forums but perhaps it is more appropriate to ask here:

Does Revit or Dynamo have an internal dictionary or something that can be accessed to store information temporarily? I’m thinking of something similar to Rhino with scriptcontext.sticky which is a builtin dictionary that allows me to save user inputs and command settings for the duration of the document open session.

I noticed dynamo player does this automatically with inputs, but if I want to obtain user information from a form, I don’t know of a way to store that info for subsequent usage of that script. Would be nice if we could access that storage.

If there isn’t a built-in solution, I’m fine with pickling or exporting info to a text file instead. In this case, does anyone know of a good place to store this file so that it will exist while revit is open but deleted when the project or revit is closed?

Thanks in advance for any input!

These two nodes in the Springs package may be of interest to you: image

1 Like

If you look into pyRevit, There is a memory append and memory subtract feature. It does basically what you asking wherein a text file is written outside of both environments and stored for the session.

Along with that are clearing, replaying, and purging, so they actually in theory are extended outside of the session as well.

What your describing in computing terms is a persistent global. 3dMax utilizes this extensively in their SDK which is why you need the garbage collection function gc() to clean out your system once in a while.

1 Like