using Autodesk.Revit.DB;
|
using Autodesk.Revit.UI;
|
using Glodon.Revit.Utility;
|
using HStation.RevitDev.RevitDataExport.Entity;
|
using HStation.RevitDev.RevitDataExport.Utility;
|
using System;
|
using System.Collections.Generic;
|
using System.Text.RegularExpressions;
|
|
namespace HStation.RevitDev.RevitDataExport.Parser
|
{
|
public abstract class BaseParser
|
{
|
public abstract string GetParserName();
|
|
public abstract List<BuiltInCategory> FilterCategories { get; }
|
|
public abstract List<string> FilterRegexes { get; }
|
|
public bool IsPass(Element elem)
|
{
|
if (FilterCategories.Contains((BuiltInCategory)(elem.Category.Id.IntegerValue)))
|
{
|
var elemName = ParameterOperator.GetParameterValueAsValueString(elem, "族与类型", BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM);
|
foreach (var pattern in FilterRegexes)
|
{
|
if (Regex.IsMatch(elemName, pattern))
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
return false;
|
}
|
|
public List<Tuple<string, string>> CommonPropertyParse(Element elem)
|
{
|
var result = new List<Tuple<string, string>>
|
{
|
new Tuple<string, string>("名称", ParameterOperator.GetElementName(elem)),
|
new Tuple<string, string>("ID", elem.Id.IntegerValue.ToString()),
|
new Tuple<string, string>("系统类型", ParameterOperator.GetElementPipingSystemType(elem)?.Name),
|
new Tuple<string, string>("包围框", BoundingBoxHelper.BoundingBoxSerialize(elem.get_BoundingBox(null))),
|
new Tuple<string, string>("楼层",elem.GetParameterByProName("参照标高")==null?elem.GetParameterByProName("标高").AsValueString(): elem.GetParameterByProName("参照标高").AsValueString())
|
};
|
|
return result;
|
}
|
|
|
public abstract List<Tuple<string, string>> PropertyParse(Element elem);
|
|
public abstract ElementModel Parse(Element elem);
|
|
public ElementModel BaseParse(Element elem)
|
{
|
var elemName = ParameterOperator.GetElementName(elem);
|
var elemId = elem.Id.IntegerValue.ToString();
|
var sysName = ParameterOperator.GetElementPipingSystemType(elem)?.Name;
|
var box = BoundingBoxHelper.BoundingBoxSerialize(elem.get_BoundingBox(null));
|
var refLevel = elem.GetParameterByProName(new List<string> { "参照标高", "标高" })?.AsValueString();
|
return new ElementModel
|
{
|
名称 = elemName,
|
编号 = elemId,
|
包围框 = box,
|
系统类型 = sysName,
|
楼层 = refLevel,
|
连接构件 = ElementExtense2.GetLinkedElementIds(elemId)
|
};
|
}
|
}
|
}
|