示例#1
0
            //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.
            //
            //If any ON_BinaryArchive::Read*() functions return false than you should
            //immediately return false otherwise return true when all data was read.
            protected override void ReadDocument(Rhino.RhinoDoc doc, Rhino.FileIO.BinaryArchiveReader archive, Rhino.FileIO.FileReadOptions options)
            {
                //Always read data in the EXACT same order you wrote it
                int major, minor;

                archive.Read3dmChunkVersion(out major, out minor);

                //If you've changed your reading/writing code over time,
                //you can use the version number of what you read
                //to figure out what can be read from the archive
                if ((major > 1 | minor > 0))
                {
                    return;
                }

                //the data you read/write will probably be member variables of your plug-in class,
                //but for simplicity this sample is just using locally defined strings
                string date_string = archive.ReadString();
                string time_string = archive.ReadString();

                //Get the commands for "Insert_Source" and "Insert_Receiver". This is where the Source and Receiver conduits are stored.
                UI.Pach_Source_Object   S_command = Pach_Source_Object.Instance;
                UI.Pach_Receiver_Object R_command = Pach_Receiver_Object.Instance;

                System.Guid objectId = default(System.Guid);
                string      Type     = null;

                do
                {
                    try
                    {
                        objectId = archive.ReadGuid();
                        Type     = archive.ReadString();
                        if (Type == "Source")
                        {
                            Rhino.DocObjects.RhinoObject Source = doc.Objects.Find(objectId);
                            if (Source != null)
                            {
                                SourceConduit.Instance.SetSource(Source);
                                doc.Views.Redraw();
                            }
                        }
                        else if (Type == "Receiver")
                        {
                            Rhino.DocObjects.RhinoObject Receiver = doc.Objects.Find(objectId);
                            if (Receiver != null)
                            {
                                ReceiverConduit.Instance.SetReceiver(Receiver);
                                doc.Views.Redraw();
                            }
                        }
                        Type = null;
                    }catch (Exception)
                    {
                        break;
                    }
                }while (objectId != null);
            }
示例#2
0
        protected override bool Read(Rhino.FileIO.BinaryArchiveReader archive)
        {
            int major, minor;

            archive.Read3dmChunkVersion(out major, out minor);
            if (1 == major && 0 == minor)
            {
                Notes = archive.ReadString();
            }
            return(!archive.ReadErrorOccured);
        }