using Autodesk.Revit.DB;
|
using Autodesk.Revit.DB.Plumbing;
|
using Glodon.Revit.Utility;
|
using HStation.RevitDev.RevitDataExport.Common;
|
using System;
|
using System.Collections.Generic;
|
using HStation.RevitDev.Model.AttributeClass;
|
using HStation.RevitDev.RevitDataExport.Entity;
|
using HStation.RevitDev.RevitDataExport.Entity.ElementModels;
|
using HStation.RevitDev.RevitDataExport.Utility;
|
using System.Linq;
|
|
namespace HStation.RevitDev.RevitDataExport.Parser
|
{
|
/// <summary>
|
/// 管道
|
/// </summary>
|
///
|
[RevitType(Model.ModelEnum.RevitType.RFT_Pipe)]
|
public class PipeParser : BaseParser
|
{
|
public override List<BuiltInCategory> FilterCategories
|
{
|
get
|
{
|
return new List<BuiltInCategory>
|
{
|
BuiltInCategory.OST_PipeCurves
|
};
|
}
|
}
|
public override List<string> FilterRegexes
|
{
|
get
|
{
|
return new List<string>
|
{
|
""
|
};
|
}
|
}
|
|
public override string GetParserName()
|
{
|
return "管道";
|
}
|
|
public override ElementModel Parse(Element elem)
|
{
|
var elemModel = BaseParse(elem);
|
var result = new PipeModel(elemModel);
|
if (elem is Pipe pipe)
|
{
|
var diameter = pipe.Diameter.FeetToMM().ToString();
|
var length = ParameterOperator.GetParameterValueAsString(pipe, "长度");
|
var flow = ParameterOperator.GetParameterValueAsString(pipe, "流量");
|
var flowSpeed = ParameterOperator.GetParameterValueAsString(pipe, "流速");
|
var pressureLoss = ParameterOperator.GetParameterValueAsString(pipe, "压力损失");
|
var specificFriction = ParameterOperator.GetParameterValueAsString(pipe, "比摩阻");
|
result.编号 = elemModel.编号;
|
result.连接构件 = ElementExtense2.GetLinkedElementIds(elemModel.编号);
|
result.直径 = diameter;
|
result.长度 = length;
|
result.流量 = flow;
|
result.流速 = flowSpeed;
|
result.压力损失 = pressureLoss;
|
result.比摩阻 = specificFriction;
|
}
|
|
return result;
|
}
|
|
|
|
public override List<Tuple<string, string>> PropertyParse(Element elem)
|
{
|
var result = new List<Tuple<string, string>>();
|
var pipe = elem as Pipe;
|
if (pipe == null) { return result; }
|
var connectInfos = MEPHelper.GetConnecters(pipe);
|
result.AddRange(CommonPropertyParse(elem));
|
for (int i = 1; i <= 2; i++)
|
{
|
if (connectInfos.Count >= i)
|
{
|
result.Add(new Tuple<string, string>($"连接点{i}", connectInfos[i - 1]?.ElementId.ToString()));
|
}
|
else
|
{
|
result.Add(new Tuple<string, string>($"连接点{i}", string.Empty));
|
}
|
}
|
|
//端点
|
var location = pipe.Location as LocationCurve;
|
if (location != null)
|
{
|
var start = location.Curve.GetEndPoint(0);
|
var end = location.Curve.GetEndPoint(1);
|
var standardStart = new XYZ(start.X * 304.8, start.Y * 304.8, start.Z * 304.8);
|
var standardEnd = new XYZ(end.X * 304.8, end.Y * 304.8, end.Z * 304.8);
|
result.Add(new Tuple<string, string>("端点", JsonHelper.ToJson(new { standardStart, standardEnd })));
|
}
|
|
// 直径
|
result.Add(new Tuple<string, string>($"直径", pipe.Diameter.FeetToMM().ToString()));
|
|
// 长度
|
var length = ParameterOperator.GetParameterValueAsString(pipe, "长度"); //(pipe.Location as LocationCurve).Curve.Length.FeetToMM();
|
result.Add(new Tuple<string, string>($"长度", (decimal.Parse(length.ToString()) / 1000).ToString()));
|
|
// 流量
|
var flow = ParameterOperator.GetParameterValueAsString(pipe, "流量");
|
result.Add(new Tuple<string, string>($"流量", flow.ToString()));
|
|
// 流速
|
var flowSpeed = ParameterOperator.GetParameterValueAsString(pipe, "流速");
|
result.Add(new Tuple<string, string>($"流速", flowSpeed.ToString()));
|
|
// 压力损失
|
var pressureLoss = ParameterOperator.GetParameterValueAsString(pipe, "压力损失");
|
result.Add(new Tuple<string, string>($"压力损失", pressureLoss.ToString()));
|
|
// 比摩阻
|
var specificFriction = ParameterOperator.GetParameterValueAsString(pipe, "比摩阻");
|
result.Add(new Tuple<string, string>($"比摩阻", specificFriction.ToString()));
|
return result;
|
}
|
}
|
}
|