Avoid saving and loading plug-in data when Exporting objects


How can we avoid to save and load plug-in data when Exporting Rhino objects while the plug-in is running?

Thank you!

Hi @cristina.b,

use the hyphened version of _-SaveAs or _-Export command and set _SavePluginData=_No.


Hi Cristina,

If you don’t want to write your plug-in’s document user data when Rhino is exporting, then you plug-in object’s ShouldCallWriteDocument member should look something like this:

/// <summary>
/// Called whenever a Rhino is about to save a .3dm file.  
/// If you want to save plug-in document data when a model 
/// is saved in a version 5 .3dm file, then you must override
/// this function to return true and you must override the 
/// WriteDocument() member.
/// </summary>
protected override bool ShouldCallWriteDocument(FileWriteOptions options)
  if (
    options.WriteGeometryOnly || 
    options.WriteSelectedObjectsOnly || 
    return false;

  // TODO...
  return 0 != MyDocumentDataCount();

Likewise, when reading you plug-in’s document data, check the FileReadOptions argument to determine whether not not to keep the data you’ve read.

IMPORTANT: If you plug-in has written document user data, then when your plug-in’s ReadDocument member is called you must read your data. After you’ve read your data, you can determine whether or not you want to keep it or use it based on the FileReadOptions argument.

For example:

 /// <summary>
/// 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.
/// </summary>
protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
  int major;
  int minor;
  archive.Read3dmChunkVersion(out major, out minor);
  if (MAJOR == major && MINOR == minor)
    // Always read user data even though you might not use it...
    string[] string_table = archive.ReadStringArray();
    if (null != string_table && !options.ImportMode)

Does this help?

– Dale

Hi Dale,

It works!
Thank you very much!