# Reading plugin data when importing from a 3dm file

**URL:** <https://discourse.mcneel.com/t/reading-plugin-data-when-importing-from-a-3dm-file/107629>\
**Category:** Rhino Developer\
**Tags:** plugin, import\
**Created:** [August 25, 2020, 3:29pm UTC](https://discourse.mcneel.com/t/reading-plugin-data-when-importing-from-a-3dm-file/107629 "2020-08-25T15:29:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![p.stragliotto](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/p.stragliotto/32/702136_2.png) [@p.stragliotto](https://discourse.mcneel.com/u/p.stragliotto)\
**Post date:** [August 25, 2020, 3:29pm UTC](https://discourse.mcneel.com/t/reading-plugin-data-when-importing-from-a-3dm-file/107629/1 "2020-08-25T15:29:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [August 27, 2020, 5:11pm UTC](https://discourse.mcneel.com/t/reading-plugin-data-when-importing-from-a-3dm-file/107629/2 "2020-08-27T17:11:01Z")

</div>

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](https://mcneel.myjetbrains.com/youtrack/issue/RH-60129)

– Dale

---

<div class="post-metadata">

**Author:** ![p.stragliotto](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/p.stragliotto/32/702136_2.png) [@p.stragliotto](https://discourse.mcneel.com/u/p.stragliotto)\
**Post date:** [August 28, 2020, 8:22am UTC](https://discourse.mcneel.com/t/reading-plugin-data-when-importing-from-a-3dm-file/107629/3 "2020-08-28T08:22:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [August 28, 2020, 3:27pm UTC](https://discourse.mcneel.com/t/reading-plugin-data-when-importing-from-a-3dm-file/107629/4 "2020-08-28T15:27:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![brian](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/brian/32/504171_2.png) [@brian](https://discourse.mcneel.com/u/brian)\
**Post date:** [September 1, 2020, 11:33pm UTC](https://discourse.mcneel.com/t/reading-plugin-data-when-importing-from-a-3dm-file/107629/5 "2020-09-01T23:33:15Z")

</div>

[RH-60129](https://mcneel.myjetbrains.com/youtrack/issue/RH-60129) is fixed in the latest [WIP](https://discourse.mcneel.com/t/welcome-to-serengeti/9612)

---

<div class="post-metadata">

**Author:** ![brian](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/brian/32/504171_2.png) [@brian](https://discourse.mcneel.com/u/brian)\
**Post date:** [October 1, 2020, 1:15am UTC](https://discourse.mcneel.com/t/reading-plugin-data-when-importing-from-a-3dm-file/107629/6 "2020-10-01T01:15:10Z")

</div>

[RH-60129](https://mcneel.myjetbrains.com/youtrack/issue/RH-60129) is fixed in the latest [BETA](https://discourse.mcneel.com/t/welcome-to-serengeti/9612)
