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);
        }
        /// <summary>
        /// Called when Rhino is saving a .3dm file to allow the plug-in to save document user data.
        /// </summary>
        protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options)
        {
            archive.Write3dmChunkVersion(MAJOR, MINOR);
            SampleCsStringTable string_table = SampleCsStringTable.Instance;

            string_table.WriteDocument(doc, archive, options);
        }
        /// <summary>
        /// Write to binary archive
        /// </summary>
        public bool WriteDocument(BinaryArchiveWriter archive)
        {
            var rc = false;

            if (null != archive)
            {
                try
                {
                    archive.Write3dmChunkVersion(MAJOR, MINOR);
                    archive.WriteInt(Count);
                    for (var i = 0; i < Count; i++)
                    {
                        var item = this.ElementAt(i);
                        archive.WriteString(item.Key);
                        item.Value.WriteToArchive(archive);
                    }
                    rc = archive.WriteErrorOccured;
                }
                catch
                {
                    // ignored
                }
            }
            return(rc);
        }
 /// <summary>
 /// Writes the content of this data to a stream archive.
 /// </summary>
 protected override bool Write(BinaryArchiveWriter archive)
 {
     archive.Write3dmChunkVersion(1, 0);
     archive.WritePlane(Plane);
     archive.WriteGuid(ViewportId);
     archive.WriteBool(Enabled);
     return(!archive.WriteErrorOccured);
 }
示例#5
0
 /// <summary>
 /// Called when Rhino is saving a .3dm file to allow the plug-in to save document user data.
 /// </summary>
 protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options)
 {
     // Write the version of our document data
     archive.Write3dmChunkVersion(MAJOR, MINOR);
     // Write the string table
     StringDocumentDataTable.WriteDocument(archive);
     // Write the simple table
     SimpleDocumentDataTable.WriteDocument(archive);
     // Write the dictionary
     archive.WriteDictionary(Dictionary);
 }
        public bool WriteToArchive(BinaryArchiveWriter archive)
        {
            archive.Write3dmChunkVersion(1, 0);

            //HBObject, orphaned objects
            var dic = Serialize();

            archive.WriteDictionary(dic);

            return(!archive.WriteErrorOccured);
        }
        /// <summary>
        /// Writes the content of this data to a stream archive.
        /// </summary>
        protected override bool Write(BinaryArchiveWriter archive)
        {
            // Write the chuck version
            archive.Write3dmChunkVersion(MAJOR_VERSION, MINOR_VERSION);

            // Write 1.0 fields
            archive.WriteString(Notes);

            // Note, if you every roll the minor version number,
            // then write those fields here.

            return(!archive.WriteErrorOccured);
        }
示例#8
0
        /// <summary>
        /// Write to binary archive
        /// </summary>
        public bool Write(BinaryArchiveWriter archive)
        {
            var rc = false;

            if (null != archive)
            {
                try
                {
                    archive.Write3dmChunkVersion(MAJOR, MINOR);
                    archive.WriteInt(Value);
                    rc = archive.WriteErrorOccured;
                }
                catch
                {
                    // ignored
                }
            }
            return(rc);
        }
示例#9
0
        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);
        }
示例#10
0
        /// <summary>
        /// Write to binary archive
        /// </summary>
        public bool WriteDocument(BinaryArchiveWriter archive)
        {
            var rc = false;

            if (null != archive)
            {
                try
                {
                    archive.Write3dmChunkVersion(MAJOR, MINOR);
                    archive.WriteInt(Count);
                    for (var i = 0; i < Count; i++)
                    {
                        this[i].Write(archive);
                    }
                    rc = archive.WriteErrorOccured;
                }
                catch
                {
                    // ignored
                }
            }
            return(rc);
        }
 /// <summary>
 /// Write to binary archive
 /// </summary>
 public void WriteDocument(BinaryArchiveWriter archive)
 {
     archive.Write3dmChunkVersion(MAJOR, MINOR);
     archive.WriteStringArray(m_string_table);
 }
 protected override bool Write(BinaryArchiveWriter archive)
 {
     archive.Write3dmChunkVersion(1, 0);
     Data.Write(archive);
     return(!archive.WriteErrorOccured);
 }
 protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options)
 {
     archive.Write3dmChunkVersion(1, 0);
     this.ModelEntityTable.WriteDocument(archive);
 }
 /// <summary>
 /// Called when Rhino is saving a .3dm file to allow the plug-in to save document user data.
 /// </summary>
 public void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options)
 {
     archive.Write3dmChunkVersion(MAJOR, MINOR);
     archive.WriteStringArray(m_strings);
 }
 /// <summary>
 /// Called when Rhino is saving a .3dm file to allow the plug-in to save document user data.
 /// </summary>
 protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options)
 {
     archive.Write3dmChunkVersion(MAJOR, MINOR);
     archive.WriteDictionary(m_dictionary);
 }