Example #1
0
        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);
        }
Example #2
0
        //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);
        }