qin
2024-08-27 8d6cdf37178ba699f04d61dbaee89f81ff83c488
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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;
        }
    }
}