123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using Autodesk.Revit.DB;
- namespace RevitExport.Export
- {
- /// <summary>
- /// 元素包装
- /// </summary>
- public class ElementWrapper
- {
- public ElementWrapper(Element element)
- {
- RefElement = element;
- IsRevitElement = true;
- UseDefaultCategory();
- SourceId = element.Id.ToString();
- }
- public ElementWrapper(object instance,string sourceId)
- {
- RefObject = instance;
- IsRevitElement = false;
- UseDefaultCategory();
- SourceId = sourceId;
- }
- public bool IsRevitElement { get; private set; }
- /// <summary>
- /// 使用默认的分类
- /// </summary>
- public void UseDefaultCategory()
- {
- Category = IsRevitElement ? RefElement.GetType().FullName : RefObject.GetType().FullName;
- }
- public Element RefElement { get; private set; }
- public string Category { get; set; }
- public string SourceId { get; private set; }
- #region 普通对象处理
- public object RefObject{ get; private set; }
- public T GetObject<T>()
- {
- return (T)RefObject;
- }
-
- #endregion
- }
- }
|