Custom User Data

Hi,
I’ve got a bug with my custom UserData:

_DeckRooms = New List(Of String)({"This", "is", "a", "test"})
_DeckName = "This is a test"
 Dim dict = New Rhino.Collections.ArchivableDictionary(1, "MSPLayerData")
    dict.[Set]("DeckRooms", _DeckRooms)
    dict.[Set]("DeckName", _DeckName)
    archive.WriteDictionary(dict)

While I’m not closing Rhino, it works fine, I can read and write my user data (both my list(of string) and my string variable).
When I close/re-open rhino, my list(of string) Dictionary entries are lost, while my string objects are still there. I’ve got the same issue with every Custom UserData, doesn’t matter where they are stored (One is on the layers, another on the objects…)

I’m using Rhino RC 6.5

I guess I could bypass the issue by converting my list(of string) to a kind of CSV string, but it does not feel right to do that

Hi @Matthieu_from_NAVINN,

See if the attached sample is of any help.

TestMatthieu.zip (26.7 KB)

– Dale

Thanks for your help, @dale .
As far as I can understand, your sample attach user data to the doc, it would not work to attach a list(of object) to my layers or rhino object, would it?

I don’t really get the issue with my code actually, since Rhino.Collections.ArchivableDictionary.set() allows IEnumerable(Of String) it should work the exact same way as for storing a single string in the same dictionary, doesn’t it?

Anyway, right now I cheating by storing a string like this:

Dim DeckRoomsCSV As String = ""
For Each tp As String In _DeckRooms
    DeckRoomsCSV &= tp & "##"
Next
    dict.[Set]("DeckRoomsCSV", DeckRoomsCSV)

And I read it like this:

If dict.ContainsKey("DeckRoomsCSV") Then
      Dim DeckRoomsCSV As String = TryCast(dict("DeckRoomsCSV"), String)
      For Each tp As String In DeckRoomsCSV.Split("##")
            If tp <> "" Then _DeckRooms.Add(tp)
      Next
End If

Hi @Matthieu_from_NAVINN,

Yes, it will work on objects too.

– Dale

Ok thanks @dale , I’ll try this when I’ve got some time (My current code works with the CSV trick)