Incorporating other files into 3dm

Say I have a zip-archive containing a few files, is it possible to store some of these files in a Rhino .3dm file?

I’m developing this workflow that starts in the browser:

  • user inputs some basic geometric information about a project
  • web-app generates a couple of files (most importantly a few JSON files containing project and geometry settings and an Excel template for later use) and stores them in a zip-archive
  • my addin will open that zip-archive, translate the JSON files into Rhino layers, geometry and a UserDictionary for some of the settings I guess. Now, I’d like to store that Excel-file somewhere within the Rhino Model (UserData? How?)
  • user can now work on the geometry in Rhino
  • my addin later pulls that ol’Excel-template from the hat, fills in some data obtained from the Rhino model and tadaaa, you’re left with your final product, an Excel-sheet.

Why not implement this another way?
Let’s just keep this short, I know there are other ways of doing this (like generating the Excel-sheet on the fly after the fact) - for now, let’s just assume that there are some reasons why I’d like to implement it this way. How would I go about storing that Excel-template in my Rhino model?

You’ll want to look into implementing the PlugIn.ShouldCallWriteDocument Method along with PlugIn.WriteDocument Method . See this search result for pointers to example code in C# et al:

Or, as the WriteDocument documentation states you could use BinaryArchiveWriter and BinaryArchiveReader to do what you need. See for instance this example:

1 Like