public static dynElem ModifyElement(SerialElement serialElement, [DefaultArgument("Synthetic.Revit.Document.Current()")] RevitDoc document) { dynElem elem = null; Type type = serialElement.GetType(); if (type == typeof(SerialMaterial)) { elem = SerialMaterial.ModifyMaterial((SerialMaterial)serialElement, document); } else if (type == typeof(SerialElementType)) { elem = SerialElementType.ModifyElement((SerialElementType)serialElement, document); } else if (type == typeof(SerialHostObjType)) { elem = SerialHostObjType.ModifyWallType((SerialHostObjType)serialElement, document); } else if (type == typeof(SerialView)) { elem = SerialView.ModifyView((SerialView)serialElement, document); } else { elem = SerialElement.ModifyElement((SerialElement)serialElement, document); } return(elem); }
private void _sortSerialElement(SerialElement serialElement) { Type type = serialElement.GetType(); if (type == typeof(SerialMaterial)) { this.Materials.Add(serialElement.Name, (SerialMaterial)serialElement); } else if (type == typeof(SerialElementType)) { this.ElementTypes.Add(serialElement.Name, (SerialElementType)serialElement); } else if (type == typeof(SerialHostObjType)) { this.HostObjTypes.Add(serialElement.Name, (SerialHostObjType)serialElement); } else if (type == typeof(SerialView)) { this.Views.Add(serialElement.Name, (SerialView)serialElement); } else { this.Elements.Add((SerialElement)serialElement); } }
public static SerialElement ByRevitElement(RevitElem revitElement) { SerialElement serializeElement = null; if (revitElement != null) { serializeElement = _serialByType(revitElement); } return(serializeElement); }
public static List <dynElem> ModifyElements(SerialListElement ListJSON, revitDoc doc) { List <dynElem> elems = new List <dynElem>(); foreach (SerialElement e in ListJSON.Elements) { elems.Add(SerialElement.ModifyElement(e, doc)); } return(elems); }
public static SerialElement ByDynamoElement(dynElem dynamoElement) { SerialElement serializeElement = null; RevitElem revitElement = dynamoElement.InternalElement; if (dynamoElement != null) { serializeElement = _serialByType(revitElement); } return(serializeElement); }
//public static SerialElement DeserializeByJson (string Json) //{ // SerialElement serialElem = JsonConvert.DeserializeObject<SerialElement>(Json); // switch (serialElem.Class) // { // case "Autodesk.Revit.DB.Material": // serialElem = JsonConvert.DeserializeObject<SerialMaterial>(Json); // break; // case "Autodesk.Revit.DB.ElementType": // case "Autodesk.Revit.DB.TextNoteType": // case "Autodesk.Revit.DB DimensionType": // serialElem = JsonConvert.DeserializeObject<SerialElementType>(Json); // break; // default: // break; // } // return serialElem; //} //public static string SerializeToJson (SerialElement serialElement) //{ // SerializeJSON serializeJSON = new SerializeJSON(); // serializeJSON._sortSerialElement(serialElement); // return Newtonsoft.Json.JsonConvert.SerializeObject(serializeJSON, Formatting.Indented); //} #endregion #region Serialization Helper Functions private static SerialElement _serialByType(RevitElem revitElement) { SerialElement serializeElement = null; string revitType = revitElement.GetType().FullName; switch (revitType) { case "Autodesk.Revit.DB.Material": serializeElement = new SerialMaterial((RevitMaterial)revitElement); break; case "Autodesk.Revit.DB.ElementType": case "Autodesk.Revit.DB.TextNoteType": case "Autodesk.Revit.DB DimensionType": serializeElement = new SerialElementType((RevitElemType)revitElement); break; case "Autodesk.Revit.DB.WallType": case "Autodesk.Revit.DB.FloorType": case "Autodesk.Revit.DB.CeilingType": case "Autodesk.Revit.DB.RoofType": case "Autodesk.Revit.DB.BuildingPadType": serializeElement = new SerialHostObjType((RevitHostObjType)revitElement); break; case "Autodesk.Revit.DB.View": case "Autodesk.Revit.DB.TableView": case "Autodesk.Revit.DB.View3D": case "Autodesk.Revit.DB.ViewDrafting": case "Autodesk.Revit.DB.ViewPlan": case "Autodesk.Revit.DB.ViewSection": case "Autodesk.Revit.DB.ViewSheet": serializeElement = new SerialView((RevitView)revitElement); break; default: serializeElement = new SerialElement(revitElement); break; } return(serializeElement); }