Archivable Dictionary - storing an `object` in the UserDictionary [solved]

Hello all, I’m upping the game for Speckle’s user data utils (https://speckle.works/doc/userdatautils/) and I need some loving advice…

Question number one: is there an all encompassing type that has UserDictionary as a property? I’m getting really lost around, especially when it comes to points & polylines, boxes (understand they are structs, but…).

Question number two: I’m generally trying to set stuff in UserDictionarys of RhinoCommon objects - generic (serializable) stuff, usually. Nevertheless, this obviously fails, and I’m forced to do quite a long dance when it comes to casting things around back and forth.

More to the point:

  • Would it be possible to have a .SetObject(ISerliazable obj) method?
  • Wouldn’t it be wonderful if the ArchivableDictionary would just be a simple Dictionary<string, ISerializable>?

I’m sure there’s valid internal reasons that escape my limited knowledge, but I’m curious.

thanks! :sunny:

Hi Dimitrie,
The ArchivableDictionary supports a fixed set of types. One of them is a byte array which you could use to save/restore generic data. Here’s a StackOverflow post on converting objects to byte arrays

The ArchivableDictionary property is defined on the Rhino.Runtime.CommonObject class so it should be available to any class that derives from CommonObject

Hey steve,
ah sweet, why didn’t i think of that? I’m already converting to byte[] complicated nurbs stuff to send back and forth, why didn’t I think of doing the same here? :man_facepalming:

This is great stuff – I am basically in search of the same – the ability to store arbitrary data types. I assume you solved this for Speckle… curious if there are any performance implications for storing everything as a byte array, regardless if whether it is a simple type?

Cheers,
Marc