Persistence using c#/VB script component possible?

Hello ,

I know you can override read and write of GH_IO.Serialization inside a custom component to gain persistence. But is it possible to get this behaviour using a script component instead? If not, is there an alternative method to gain persistence in another way, without writing to an external file.

I do not want to use custom components because that requires used to download and install a plugin.

Cheers

update: i found this thread: https://www.grasshopper3d.com/forum/topics/key-value-user-text-within-grasshopper-document. will see whether it solves my problem.

If you want to store global data, you can use the GH_SettingsServer from

Grasshopper.Instances.Settings

where you can write and read using

Grasshopper.Instances.Settings.SetValue(),
Grasshopper.Instances.Settings.GetValue()

which will be written to grasshopper_kernel.xml (in GH’s folder) when you call

Grasshopper.Instances.Settings.WritePersistentSettings()

Will this be saved with the gh file? lets say i save some settings, then i transfer the file to another computer, will i be able to pull up those settings again?

No, this are user settings, no document metadata.

In that case you can store your data in a named panel component from the Script Component and let the people who read that document do not delete that panel. If you want to store no text data there, use the GH_IO.Serialization.GH_LooseChunk class to serialize your data to xml/binary and send that text to the panel. Then you can search the panel by its name and deserialize the data with GH_LooseChunk.

store your data in a named panel component from the Script Component

Can you elaborate on this? an example perhaps?