123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /*-------------------------------------------------------------------------
- * 功能描述:ElementWrapperFactory
- * 作者:xulisong
- * 创建时间: 2019/6/24 8:44:46
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Autodesk.Revit.DB;
- using RevitExport;
- using RevitExport.Export;
- using SAGA.RevitUtils.Extends;
- using SAGA.RevitUtils.MEP;
- namespace RevitToJBim.Common
- {
- /// <summary>
- /// 解析对象创建工厂
- /// </summary>
- public class ElementWrapperFactory
- {
- /// <summary>
- /// 根据element创建带分类对象的解析信息。便于快速过滤.
- /// 注:生成wrapper时,为了保证统一性,最好统一调用该方法
- /// </summary>
- /// <param name="element"></param>
- /// <returns></returns>
- public static ElementWrapper CreateWrapper(Element element)
- {
- if (element is FamilyInstance fi)
- {
- CreateWrapper(fi);
- }
- return new ElementWrapper(element);
- }
- /// <summary>
- /// 创建FamilyInstance的wrapper
- /// </summary>
- /// <param name="familyInstance"></param>
- /// <returns></returns>
- public static ElementWrapper CreateWrapper(FamilyInstance familyInstance)
- {
- var useFamilyType = FamilyType.Undefine;
- var category = familyInstance.Category;
- if (category != null)
- {
- var enumValue = (BuiltInCategory)category.Id.IntegerValue;
- #region category转换
- switch (enumValue)
- {
- case BuiltInCategory.OST_Doors:
- {
- useFamilyType = FamilyType.Door;
- break;
- }
- case BuiltInCategory.OST_Windows:
- {
- useFamilyType = FamilyType.Window;
- break;
- }
- case BuiltInCategory.OST_Columns:
- {
- useFamilyType = FamilyType.Column;
- break;
- }
- }
- #endregion
- }
- if (useFamilyType == FamilyType.Undefine)
- {
- //判断部件和设备
- var family = familyInstance.GetFamily();
- ///todo
- }
- if (useFamilyType == FamilyType.Undefine)
- {
- var connectors = familyInstance.GetAllConnectors();
- if (connectors.Any(c => c.Domain == Domain.DomainHvac || c.Domain == Domain.DomainPiping))
- {
- useFamilyType = FamilyType.Other;
- }
- }
- if (useFamilyType == FamilyType.Undefine)
- {
- return null;
- }
- ElementWrapper wrapper = new ElementWrapper(familyInstance);
- wrapper.Category = CategoryGenerator.BuildingCategory(useFamilyType);
- return wrapper;
- }
- }
- }
|