Can't Read a ArchivableDictionary From UserData

Hi,
While using UserData, I encountered another problem: I cannot read the ArchivableDictionary object. I declared this object as a property, and there were no errors when saving it, but when reading it, it indicates a read failure. What could be the reason for this?


You write two items: a guid and a dictionary. This means you must first read the guid and then the dictionary. You currently only read the dictionary, which fails becaus you must first read the guid.

Also a tip for user data in 3dm files: when you write user data to a 3dm file, first write a version. Then when you need to change something in the future, you can increase the version and when a file with an older version of the data gets opened, you first read the version of the data and handle the reading based on that version. For example:

write:

  • version 1.0
  • guid
  • dictionary

later you discover you also want to write a list of numbers:
write:

  • version 2.0
  • guid
  • dictionary
  • number list

now, when you read:

  • version
  • guid
  • dictionary
  • if version == 2.0:
    • read number list
1 Like

thank you .
Oh, does this mean that both writing and reading must follow a specific order?
Is the writing of userdata similar to binary writing?

I have tried reading and writing in a specific order. UserData can now be successfully written to a .3dm file and can also be read from the .3dm file.

Yes, the order is important as you’ve already found out :slight_smile:

1 Like