//If any ON_BinaryArchive::Write*() functions return false than you should //immediately return false otherwise return true if all data was written //successfully. Returning false will cause Rhino to stop writing this document. protected override void WriteDocument(Rhino.RhinoDoc doc, Rhino.FileIO.BinaryArchiveWriter archive, Rhino.FileIO.FileWriteOptions options) { //This function is called because ShouldCallWriteDocument returned True. //Write your plug-in data to the document string date_string = System.DateTime.Now.ToShortDateString(); string time_string = System.DateTime.Now.ToShortTimeString(); //It is a good idea to always start with a version number //so you can modify your document read/write code in the future archive.Write3dmChunkVersion(1, 0); archive.WriteString(date_string); archive.WriteString(time_string); UI.Pach_Source_Object S_command = Pach_Source_Object.Instance; UI.Pach_Receiver_Object R_command = Pach_Receiver_Object.Instance; foreach (System.Guid ID in SourceConduit.Instance.UUID) { System.Guid N_ID = new System.Guid(ID.ToString()); archive.WriteGuid(N_ID); archive.WriteString("Source"); } foreach (System.Guid ID in ReceiverConduit.Instance.UUID) { System.Guid N_ID = new System.Guid(ID.ToString()); archive.WriteGuid(N_ID); archive.WriteString("Receiver"); } }
//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); }
public bool SourceRef(out List <Rhino.DocObjects.RhinoObject> Points) { UI.Pach_Source_Object S_command = Pach_Source_Object.Instance; Points = new List <Rhino.DocObjects.RhinoObject>(); for (int i = 0; i < SourceConduit.Instance.UUID.Count; i++) { System.Guid S_ID = SourceConduit.Instance.UUID[0]; if (S_ID != System.Guid.Empty || S_ID != System.Guid.NewGuid()) { Points.Add(Rhino.RhinoDoc.ActiveDoc.Objects.Find(S_ID)); } } if (Points.Count > 0) { return(true); } Points = null; return(false); }