The problem is that the plugin is loaded after the document has already been loaded, so ReadDocument is never called.
Here’s the steps to create a 3dm file that contains two user tables for a single plugin:
- Install a plugin that saves data with WriteDocument/ReadDocument
- Create a 3dm file and save it (now the 3dm file has a user table for the plugin)
- Uninstall the plugin (or just uncheck “Enabled” in Tools->Options->Plug-ins)
- Open Rhino and open the 3dm file from above
- Go to Tools->Options->Plug-ins and install the plugin (don’t close Rhino)
- Save the 3dm file
It now contains two user tables for the plugin. This can also be reproduced by installing the plugin from an RHI, then double clicking a 3dm file. This causes the “Preparing plugin for first use” thing to come up after the document has loaded, so it creates the same problem.
The question is how can we get the plugin’s ReadDocument to be called when the document has already been loaded?
This can easily be detected by getting a non-null active document in OnLoadPlugin. But how can we load our plugin data out of the document if the document is already loaded? Or we could just force a revert the file I suppose.