zhangyuekai
2024-07-01 0e3464b6adf776686e66bb3189441ab1a65a088e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Plumbing;
using Glodon.Revit.Utility;
using HStation.RevitDev.RevitDataExport.Common;
using HStation.RevitDev.RevitDataExport.Utility;
using HStation.RevitDev.RevitDataExport.Utils;
using System;
using System.Collections.Generic;
 
namespace HStation.RevitDev.RevitDataExport.Parser
{
    /// <summary>
    /// 管道
    /// </summary>
    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 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.GetParameterValueAsDouble(pipe, "流量");
            result.Add(new Tuple<string, string>($"流量", flow.ToString()));
 
            // 流速
            var flowSpeed = ParameterOperator.GetParameterValueAsDouble(pipe, "流速");
            result.Add(new Tuple<string, string>($"流速", flowSpeed.ToString()));
 
            // 压力损失
            var pressureLoss = ParameterOperator.GetParameterValueAsDouble(pipe, "压力损失");
            result.Add(new Tuple<string, string>($"压力损失", pressureLoss.ToString()));
 
            // 比摩阻
            var specificFriction = ParameterOperator.GetParameterValueAsDouble(pipe, "比摩阻");
            result.Add(new Tuple<string, string>($"比摩阻", specificFriction.ToString()));
            return result;
        }
    }
}