public bool Write(BinaryArchiveWriter archive) { var rc = false; if (null != archive) { try { // Write chunk version archive.Write3dmChunkVersion(1, 0); // Write 'this' object var formatter = new BinaryFormatter(); var stream = new MemoryStream(); formatter.Serialize(stream, this); stream.Seek(0, 0); var bytes = stream.ToArray(); archive.WriteByteArray(bytes); stream.Close(); // Verify writing rc = archive.WriteErrorOccured; } catch { // TODO } } return(rc); }
protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { if (Core.Instance?.ActiveDocument != null && !options.WriteSelectedObjectsOnly) { byte[] data = Core.Instance.ActiveDocument.ToBinary(); if (data != null) { archive.Write3dmChunkVersion(0, 1); archive.WriteByteArray(data); if (archive.WriteErrorOccured) { Core.PrintLine("ERROR: Writing Salamander model to Rhino .3dm failed!"); } else { Core.PrintLine("Salamander model data written to .3dm."); } } } base.WriteDocument(doc, archive, options); }