namespace HStation.Service { /// /// 连接列表拓展 /// public static class RevitConnectListExtensions { /// /// 获取中心位置 /// /// 连接列表 /// public static Model.RevitPosition GetCenterPosition(this List list) { if (list == null || list.Count < 1) { return default; } var pts = list.Select(x => x.Position).ToList(); return pts.GetCenter(); } /// /// 获取开始连接 /// /// 连接列表 /// public static Model.RevitConnect GetStartConnect(this List list) { if (list == null || list.Count < 1) { return default; } var start = list.Find(x => x.Direction == Direction.Inlet); if (start == null) { start = list.Where(x => x.Direction == Direction.None).FirstOrDefault(); } return start; } /// /// 获取开始连接列表 /// /// 连接列表 /// public static List GetStartConnects(this List list) { if (list == null || list.Count < 1) { return default; } var starts = list.Where(x => x.Direction == Direction.Inlet).ToList(); return starts; } /// /// 获取结束连接 /// /// 连接列表 /// public static Model.RevitConnect GetEndConnect(this List list) { if (list == null || list.Count < 1) { return default; } var end = list.Find(x => x.Direction == Direction.Outlet); if (end == null) { end = list.Where(x => x.Direction == Direction.None).LastOrDefault(); } return end; } /// /// 获取结束连接列表 /// /// 连接列表 /// public static List GetEndConnects(this List list) { if (list == null || list.Count < 1) { return default; } var ends = list.Where(x => x.Direction == Direction.Outlet).ToList(); return ends; } } }