Persistent to Volatile and back


(Philip) #1

(Writing components in C#)
I want to move/copy an OUTPUT param’s VolatileData to its PersistentData regardless of the structure. I also want to do the reverse in a different context. I thought this would be simple, but I can’t figure it out. I’ve read that the first is what “Internalize Data” does, but why is it so difficult to do manually in code? And why is there no API call to do it? At this point, I’m assuming it’s intentionally forbidden (PersistentData is readonly), but I just wanted to check.


(David Rutten) #2

Outputs will not support persistent data, you may be able to assign it, but the volatile data of output parameters is always populated by the component. You should however be able to copy the volatiledata of an output to the persistent data of an input or floating parameter. Do note that you need to perform this copy after the solution completes. The three most common ways in which this happens are:

  1. In response to a UI event (button press, mouse click, keydown)
  2. By scheduling a new solution on the GH_Document and registering a callback delegate that copies the data.
  3. By handling the GH_Document.SolutionEnd or GH_Document.SolutionStart event.

You can assign persistent data using the GH_PersistentParam<T>.SetPersistentData(GH_Structure<T> data) method. The datatree will be copied superficially only.


(Philip) #3

Thanks for the reply. I figured out what I needed, and the key to my misunderstanding was the fact that you can’t set the PersistentData during the solution.