protected bool WriteHotLoadData(Rhino.Collections.ArchivableDictionary dict) { string encAss = GenerateCSharpCode(this.GetType()); dict.Set("EncodedAssembly", encAss); dict.Set("Type", this.GetType().FullName); return(true); }
protected override bool Write(Rhino.FileIO.BinaryArchiveWriter archive) { // you can implement File IO however you want... but the dictionary class makes // issues like versioning in the 3dm file a bit easier. If you didn't want to use // the dictionary for writing, your code would look something like. // // archive.Write3dmChunkVersion(1, 0); // archive.WriteInt(Weight); // archive.WriteDouble(Density); var dict = new Rhino.Collections.ArchivableDictionary(1, "Physical"); dict.Set("Weight", Weight); dict.Set("Density", Density); archive.WriteDictionary(dict); return true; }
protected override bool Write(Rhino.FileIO.BinaryArchiveWriter archive) { // you can implement File IO however you want... but the dictionary class makes // issues like versioning in the 3dm file a bit easier. If you didn't want to use // the dictionary for writing, your code would look something like. // // archive.Write3dmChunkVersion(1, 0); // archive.WriteInt(IntegerData); // archive.WriteString(StringData); var dict = new Rhino.Collections.ArchivableDictionary(1, "MyCustomData"); dict.Set("IntegerData", IntegerData); dict.Set("StringData", StringData); archive.WriteDictionary(dict); return true; }
protected override bool Write(Rhino.FileIO.BinaryArchiveWriter archive) { // you can implement File IO however you want... but the dictionary class makes // issues like versioning in the 3dm file a bit easier. If you didn't want to use // the dictionary for writing, your code would look something like. // // archive.Write3dmChunkVersion(1, 0); // archive.WriteInt(IntegerData); // archive.WriteString(StringData); var dict = new Rhino.Collections.ArchivableDictionary(1, "MyCustomData"); dict.Set("IntegerData", IntegerData); dict.Set("StringData", StringData); archive.WriteDictionary(dict); return(true); }
/// <summary> /// Set UserDictionry of Cloud for ColorGradient Used. /// </summary> public static void Set_ColorGradient_Dict(ref PointCloud Cloud, List <Color> Colors, List <double> ColorValues) { List <double> R = new List <double>(); List <double> G = new List <double>(); List <double> B = new List <double>(); foreach (Color color in Colors) { R.Add(color.R); G.Add(color.G); B.Add(color.B); } Rhino.Collections.ArchivableDictionary ColorDict = new Rhino.Collections.ArchivableDictionary(); ColorDict.Set("R", R); ColorDict.Set("G", G); ColorDict.Set("B", B); ColorDict.Set("Val", ColorValues); Cloud.UserDictionary.Set("ColorGradient", ColorDict); }
public override bool SaveObject(RhinoDoc doc, RhinoObject doc_object, ref Transform transform, BinaryArchiveWriter archive) { string name = doc_object.Name; Rhino.Collections.ArchivableDictionary userdata = doc_object.UserDictionary; userdata.Set("ObjName", name); archive.WriteDictionary(userdata); return(!archive.WriteErrorOccured); }
public void IncrementRunCommandCount() { int count = 0; object value; if (m_dict.TryGetValue("RunCommand Count", out value)) { count = (int)value; } count++; m_dict.Set("RunCommand Count", count); }
protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { var dict = new Rhino.Collections.ArchivableDictionary(1, "RigiBodyData"); //If user save during animation, save the shapes at the time when start was pressed if (!TimePanel.Instance.Restarted || TimePanel.Instance.TrackbarValue != 0) { List <RigidBody> copyToAdd = new List <RigidBody>();; for (int i = 0; i < RigidBodyManager.World.RigidBodies.Count; i++) { copyToAdd.Add(RigidBodyManager.DuplicateRigidBody(RigidBodyManager.FramesRigidBodies[0][i], RigidBodyManager.FramesRigidBodies[0][i].IsStatic)); } dict.Set("rigidBodies", RigidBodyManager.ObjectToByteArray(copyToAdd)); } else { dict.Set("rigidBodies", RigidBodyManager.ObjectToByteArray(RigidBodyManager.RigidBodies)); } dict.Set("guidList", RigidBodyManager.ObjectToByteArray(RigidBodyManager.GuidList)); dict.Set("geometryList", RigidBodyManager.ObjectToByteArray(RigidBodyManager.GeometryList)); dict.Set("MaxFrameBoxValue", (int)TimePanel.Instance.MaxFrameBoxValue); dict.Set("worldCount", RigidBodyManager.World.RigidBodies.Count); archive.WriteDictionary(dict); }
protected override bool Write(Rhino.FileIO.BinaryArchiveWriter archive) { var dict = new Rhino.Collections.ArchivableDictionary(20171031, "Values"); int i = 0; foreach (GeometrySegment geoSeg in GeometrySegments) { dict.Set("geoSeg" + i, i); dict.Set("gsBrep" + i, geoSeg.BrepGeometry); if (geoSeg.Material.GetType() == typeof(ConcreteMaterial)) { ConcreteMaterial material = geoSeg.Material as ConcreteMaterial; dict.Set("gsMaterial" + i, "Concrete"); dict.Set("gsMaterialStrength" + i, material.StrenghtClass); } else if (geoSeg.Material.GetType() == typeof(SteelMaterial)) { SteelMaterial material = geoSeg.Material as SteelMaterial; dict.Set("gsMaterial" + i, "Steel"); dict.Set("gsMaterialName" + i, material.Name); } i++; } archive.WriteDictionary(dict); return(true); }
protected override bool Write(Rhino.FileIO.BinaryArchiveWriter archive) { var dict = new Rhino.Collections.ArchivableDictionary(20181023, "Values"); dict.Set("baseBrep", BaseBrep); dict.Set("Id", Id); if (OwnerBeam != null) { dict.Set("BeamId", OwnerBeam.Id); } else { dict.Set("BeamId", -1); } dict.Set("NoBaseCurves", BaseCurves.Count); for (int i = 0; i < BaseCurves.Count; i++) { dict.Set("BaseCurve" + i, BaseCurves[i]); } if (Material.GetType() == typeof(ConcreteMaterial)) { ConcreteMaterial material = Material as ConcreteMaterial; dict.Set("Material", "Concrete"); dict.Set("MaterialStrength", material.StrengthClass); } else if (Material.GetType() == typeof(SteelMaterial)) { SteelMaterial material = Material as SteelMaterial; dict.Set("Material", "Steel"); dict.Set("MaterialName", material.StrengthClass); } archive.WriteDictionary(dict); return(true); }
protected override bool Write(Rhino.FileIO.BinaryArchiveWriter archive) { var dict = new Rhino.Collections.ArchivableDictionary(20171031, "Values"); dict.Set("Point", BasePoint); dict.Set("OutLine", OutLine); dict.Set("Diameter", _diameter); if (Material is SteelMaterial material) { dict.Set("MaterialName", material.Name); } else { dict.Set("MaterialName", "B500B"); RhinoApp.WriteLine("No material was assigned to reinforcement."); } archive.WriteDictionary(dict); return(true); }
protected override bool Write(Rhino.FileIO.BinaryArchiveWriter archive) { Rhino.Collections.ArchivableDictionary dict = new Rhino.Collections.ArchivableDictionary(1, "CustomDataClass"); base.WriteHotLoadData(dict); dict.Set("alpha", alpha); dict.Set("beta", beta); dict.Set("classA", JsonConvert.SerializeObject(classA, Formatting.Indented)); dict.Set("classB", JsonConvert.SerializeObject(classB, Formatting.Indented)); dict.Set("classC", JsonConvert.SerializeObject(classC, Formatting.Indented)); dict.Set("classD", JsonConvert.SerializeObject(classD, Formatting.Indented)); dict.Set("classE", JsonConvert.SerializeObject(classE, Formatting.Indented)); archive.WriteDictionary(dict); return(true); }
public void JSONToUD(string JSON) { dynamic obj = JsonConvert.DeserializeObject <ExpandoObject>(JSON); //Rhino.DocObjects.Custom.UserDictionary UD = new Rhino.DocObjects.Custom.UserDictionary(); Rhino.Collections.ArchivableDictionary initDict = new Rhino.Collections.ArchivableDictionary(); //Rhino.Collections.ArchivableDictionary dict = SelectedObject.Attributes.UserDictionary; //Rhino.RhinoApp.WriteLine(obj) IterateThroughJSON(obj, initDict); //dict.Set(obj.Key, initDict); ///////// Find selected Object(s) ///////// var oes = new ObjectEnumeratorSettings { SelectedObjectsFilter = true, IncludeLights = false, IncludeGrips = false, IncludePhantoms = false }; List <RhinoObject> objs = RhinoDoc.ActiveDoc.Objects.GetObjectList(oes).ToList(); foreach (RhinoObject rhObj in objs) { Rhino.Collections.ArchivableDictionary dict = rhObj.Attributes.UserDictionary; dict.Set(obj.Key, initDict); rhObj.Geometry.UserDictionary.Set("sxbuilder", dict); rhObj.Geometry.SetUserString("sxbuilder", "true"); } //SelectedObject.Geometry.UserData. //SelectedObject.Geometry.UserDictionary. }
public void IterateThroughJSON(dynamic myObj, Rhino.Collections.ArchivableDictionary myDict) { if (((IDictionary <String, object>)myObj).ContainsKey("children")) { Rhino.RhinoApp.WriteLine("is Folder"); //myDict.Set(myObj.Key) List <object> myObjChildrenKeys = new List <object>(); for (int i = 0; i < myObj.children.Count; i++) { myObjChildrenKeys.Add(myObj.children[i].Key); dynamic kvp = myObj.children[i]; System.Collections.ArrayList arrayList = new System.Collections.ArrayList(myObjChildrenKeys); int first = arrayList.IndexOf(kvp.Key.ToString()); int last = arrayList.LastIndexOf(kvp.Key.ToString()); //Rhino.RhinoApp.WriteLine(first.ToString(), "thatsmyobj"); if (((IDictionary <String, object>)kvp).ContainsKey("children")) { Rhino.Collections.ArchivableDictionary newDict = new Rhino.Collections.ArchivableDictionary(); if (first != -1 && first != last) { Rhino.RhinoApp.WriteLine("found it!"); myDict.Set(kvp.Key + " (at index " + i + ")", newDict); } else { myDict.Set(kvp.Key, newDict); } IterateThroughJSON(kvp, newDict); } else { if (kvp.Key == "Id") { Rhino.RhinoApp.WriteLine(kvp.Value); Guid myGuid = new Guid(kvp.Value); RhinoObject foundObject = Rhino.RhinoDoc.ActiveDoc.Objects.Find(myGuid); myDict.Set("Geometry", foundObject.Geometry); } else { if (first != -1 && first != last) { Rhino.RhinoApp.WriteLine("found it!"); myDict.Set(kvp.Key + " (at index " + i + ")", kvp.Value); } else { myDict.Set(kvp.Key, kvp.Value); } } } } } else // no children { Rhino.RhinoApp.WriteLine(myObj.Value); myDict.Set(myObj.Key, myObj.Value); } }