/*-------------------------------------------------------------------------
* 功能描述: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
{
///
/// 创建数据源
///
///
public static List CreateExportData(Document doc)
{
List wrappers = new List();
//应对传入元素,不是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().Select(e => new ElementWrapper(e)));
wrappers.AddRange(collector.Clone().FilterElements(BuiltInCategory.OST_MEPSpaceSeparationLines).Select(e => new ElementWrapper(e)));
var sourceSpaces = collector.Clone().FilterElements(BuiltInCategory.OST_MEPSpaces).OfType().Where(t=>t.IsSpace()).ToList();
wrappers.AddRange(sourceSpaces.Select(e => new ElementWrapper(e)));
wrappers.AddRange(collector.Clone().FilterElements().Select(e => new ElementWrapper(e)));
wrappers.AddRange(collector.Clone().FilterElements().Select(e => new ElementWrapper(e)));
var familyInstances = collector.Clone().FilterElements();
foreach (FamilyInstance familyInstance in familyInstances)
{
var tempWrapper = ElementWrapperFactory.CreateWrapper(familyInstance);
if (tempWrapper != null)
{
wrappers.Add(tempWrapper);
}
}
wrappers.AddRange(collector.Clone().FilterElements().Select(e => new ElementWrapper(e)));
wrappers.AddRange(collector.Clone().FilterElements().Select(e => new ElementWrapper(e)));
return wrappers;
}
}
}