UserDictionary ArchivableDictonary

Hi All,
I’ve been using the UserDictionary / ArchivableDictonary to store attributes with geometry, and it has been working great. I’ve been storing information via components I developed in Grasshopper as well as through a UI I put together in rhino. But I’ve run into an issue. When I change the material color of the geometric element, the attributes get erased / lost. I discovered this when I ran a python script on the geometric elements to change the material color. Has anybody ran into an issue similar to this? How could I resolve this problem? Am I doing something wrong?


It’s possible to store data on the geometry (inherits form GeometryBase), and on the object that represents the geometry (inherits from RhinoObject).
Could it be that this your information is stored on the wrong object?

Hi Menno,

Thanks for your reply. If I understand correctly, the code I’m using applies the attributes to the geometry. The snippet is below:
Dim NewGuid As Guid = Doc.Objects.Add(RHGeo, RhAtt)

I’m sorry, but that snippet makes no sense in the context of storing data in a user dictionary or archivable dictionary…

Hi Menno,
Apologies if it wasn’t clear. The function is length and didn’t want to clutter the post. Below is hopefully a better snipped of the code:

'create a new archivable dictionary
Dim TempDict As New Rhino.Collections.ArchivableDictionary()

'create a new rhino object attribute
Dim RhAtt As New Rhino.DocObjects.ObjectAttributes()

'set keys and values
TempDict.Set(key1, value1)
TempDict.Set(key2, value2)

'add archivable dictionary to the rhino attribute

'add object to rhino with attributes
Dim NewGuid As Guid = Doc.Objects.Add(RHGeo, RhAtt)

Aha, I see. You are storing the data on the object, and not on the geometry. You should also be able to store it on the RHGeo instance. Maybe then it will remain after changing the material color.

Hi Menno, finally got around to this, did a quick test and it seems to work!! More testing required.
Thanks for your help!!!