Method ReadDocument - two calls in a row when I open a .3dm file


I am developer of plugin for Rhino 5.0. I received a strange file .3dm from my client. If I am opening this file in Rhino 5.0, only geometry is loading but plugin’s tree doesn’t loading. I can’t fix this problem because the method ReadDocument is calling two time in a row. First time a user data was loaded successfully (i can see this fact in debug mode) but when the ReadDocument was called second time, empty binary archive was loaded.
From rhinosdkplugin.h about method ReadDocument: “Called whenever a Rhino document is being loaded and plug-in user data was encountered written by a plug-in with this plug-in’s GUID.” I think, when this file was written, method WriteDocument was called two time in row. But why not a one only time?

Best regards,

Can you provide the code to a sample plug-in that replicates this? This isn’t something I can repeat, nor is it something that has been reported before…

I made a sample plugin RWProblem and attached the file frontale nuovo.3dm. If you open this file the method ReadDocument will work two time in a row. But in other files this method always called only one time.RWProblem.7z (918.6 KB)

Well, I can see why CRhinoPlugIn::ReadDocument is being called twice. If you run the Audit3dmFile command, you can see that your plug-in has written two blocks of document user data

 History Record Table:
    0 history records, 24 bytes (offset 1357488 to 1357512)
  Model User Data Table:
    user table[0]: (8215035 bytes)
      Plug-in name: RhinoNC
      Plug-in id: 0E124E40-7C5C-4026-84E4-D20F764C4D5E
    user table[4]: (280 bytes)
      Plug-in name: RhinoNC
      Plug-in id: 0E124E40-7C5C-4026-84E4-D20F764C4D5E
    5 user tables, 8220858 bytes (offset 1357512 to 9578370)

So the real question is how is this done? Can your plug-in create these types of files repeatedly?

In that case, it can not. This happened for the first time.
I want to say that when this strange file is saved, your method CRhinoPlugIn::WriteDocument for some reason was called twice …
Please tell me under what conditions it is possible.

Not knowing how the file file was created, I can’t even begin to speculate what happened. But I can assure you, this isn’t normal behavior…

Thank you very much for dialogue.
So this is an exception to the rule. You will be able to help if a problem persists and it be able to repeat?

If I can repeat it (too), I can help…

Hi @dale oddly enough I recently had this same thing happen in Rhino 7 with Orca3D. I was wondering if in the intervening 9 years you may have had any clue on what might cause this to happen. Not sure if it is a clue or not but there is one object in the model that has a history record.

Hi @theleibmans,

I’ll probably need to see a file…

– Dale