12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /*-------------------------------------------------------------------------
- * 功能描述:ExportDataBuilder
- * 作者:xulisong
- * 创建时间: 2019/6/24 9:59:47
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using Autodesk.Revit.DB;
- using Autodesk.Revit.DB.Mechanical;
- using Autodesk.Revit.DB.Plumbing;
- using RevitExport.Export;
- using RevitToJBim.Common;
- using SAGA.RevitUtils.Extends;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using RevitToJBim.Extension;
- namespace RevitToJBim
- {
- public class ExportDataBuilder
- {
- /// <summary>
- /// 创建数据源
- /// </summary>
- /// <returns></returns>
- public static List<ElementWrapper> CreateExportData(Document doc)
- {
- List<ElementWrapper> wrappers = new List<ElementWrapper>();
- //应对传入元素,不是document全集的情况
- //FilteredElementCollector collector = new FilteredElementCollector(doc, elements.Select(e => e.Id).ToList());
- #region Unit
- var formatOptions = doc.GetUnits().GetFormatOptions(UnitType.UT_Length);
- ElementWrapper wrapper = new ElementWrapper(formatOptions, null);
- wrappers.Add(wrapper);
- #endregion
- FilteredElementCollector collector = new FilteredElementCollector(doc);
- wrappers.AddRange(collector.Clone().FilterElements<Wall>().Select(e => new ElementWrapper(e)));
- wrappers.AddRange(collector.Clone().FilterElements<CurveElement>(BuiltInCategory.OST_MEPSpaceSeparationLines).Select(e => new ElementWrapper(e)));
- var sourceSpaces = collector.Clone().FilterElements<SpatialElement>(BuiltInCategory.OST_MEPSpaces).OfType<Space>().Where(t=>t.IsSpace()).ToList();
- //附加逻辑判断
- // var originSpaces = collector.Clone().GetUseSpaces();
- wrappers.AddRange(sourceSpaces.Select(e => new ElementWrapper(e)));
- wrappers.AddRange(collector.Clone().FilterElements<Pipe>().Select(e => new ElementWrapper(e)));
- wrappers.AddRange(collector.Clone().FilterElements<Duct>().Select(e => new ElementWrapper(e)));
- var familyInstances = collector.Clone().FilterElements<FamilyInstance>();
- foreach (FamilyInstance familyInstance in familyInstances)
- {
- var tempWrapper = ElementWrapperFactory.CreateWrapper(familyInstance);
- if (tempWrapper != null)
- {
- wrappers.Add(tempWrapper);
- }
- }
- wrappers.AddRange(collector.Clone().FilterElements<Level>().Select(e => new ElementWrapper(e)));
- wrappers.AddRange(collector.Clone().FilterElements<Grid>().Select(e => new ElementWrapper(e)));
- return wrappers;
- }
- }
- }
|