Reading plugin data when importing from a 3dm file

Hello, we have implemented a command in our plugin that lets users import into the current model some objects from another 3dm file. The file being imported contains plugin data that we want to access.

I tried to read the file by means of File3dm class, but I can’t figure out how to retrieve the plugin data related to the model being imported.

While loading a whole file (e.g. open a file) is well managed by ReadDocument override method of the PlugIn class, I do not find so straigthforward to get the same information from a raw File3dm instance.

Do I have to read the file as a BinaryArchiveFile? Even so, how can I read the file chunk containing the plugin data I am interested in?

Thank you for any idea that will help me unravelling this matter.

Hi @p.stragliotto,

Other than knowing whether or not a 3dm file contains your plug-in’s custom document data, using File3dm.PlugInData, there is not a way to read your plug-in’s custom document data using File3dm.

If this is capability, you need, then I suggest your plug-in stores custom data as user strings on the document using RhinoDoc.Strings. In doing this, you can retrieve your custom user strings from a File3dm object using File3dm.Strings.

Let me know if you need more details.

https://mcneel.myjetbrains.com/youtrack/issue/RH-60129

– Dale

Thank you Dale,

your suggestion is useful but it doesn’t completely resolve the issue.

We need to import data from existing files, which obviously do not contain such user strings, unless we tell our users to re-open old files and save them to store the data we want in user strings, which is clearly unfeasible, since the existing file archives can be quite large.

Any other possible workarounds?

Hi @p.stragliotto,

You say importing contains plugin data that we want to access. So you can always do that - script the Import command.

Also, you can read custom document user data from a C++ plug-in. I can point you to a sample if needed.

– Dale

RH-60129 is fixed in the latest WIP

RH-60129 is fixed in the latest BETA