Bladeren bron

xls:图数据修改

xulisong 6 jaren geleden
bovenliggende
commit
bb7ae2a36e

+ 18 - 11
MBI/SAGA.DotNetUtils/Data/EdgesArray/EdgesArrayGraph.cs

@@ -91,17 +91,24 @@ namespace SAGA.DotNetUtils.Data
             if (vertex == null)
                 return null;
             V result = vertex;
-            var useVertex = FindVertex(vertex);
-            if (useVertex == null)
-            {
-                vertex.Id = GenerateVertexIndex();
-                this.m_Vertexes.Add(vertex);
-            }
-            else
-            {
-                useVertex.Merge(vertex);
-                result = useVertex;
-            }
+            //var useVertex = FindVertex(vertex);
+            /*如果是集合形式的比较,相等不传递。比如List1与List2兼容,List2与List3兼容,不能推导出List1与List3兼容
+               综合考虑,不在基类做这种数据的处理,而是直接插入点
+             */
+            vertex.Id = GenerateVertexIndex();
+            this.m_Vertexes.Add(vertex);
+            #region 重复点判断在子类去处理
+            //if (useVertex == null)
+            //{
+            //    vertex.Id = GenerateVertexIndex();
+            //    this.m_Vertexes.Add(vertex);
+            //}
+            //else
+            //{
+            //    useVertex.Merge(vertex);
+            //    result = useVertex;
+            //} 
+            #endregion
             return result;
         }
 

+ 19 - 0
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/GplotGraphParse.cs

@@ -0,0 +1,19 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:GplotGraphParse
+ * 作者:xulisong
+ * 创建时间: 2019/2/14 17:51:58
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    class GplotGraphParse
+    {
+    }
+}

+ 95 - 0
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/GplotGraphSetting.cs

@@ -0,0 +1,95 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:GraphSetting
+ * 作者:xulisong
+ * 创建时间: 2019/2/14 17:50:52
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using Autodesk.Revit.DB;
+using SAGA.RevitUtils.MEP;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    public class GplotGraphSetting
+    {
+        public GplotGraphSetting(RelationTypeShell relationShell)
+        {
+            RelationTypeShell = relationShell;
+            Domain = relationShell.IsPipeSystem() ? Domain.DomainPiping : Domain.DomainHvac;
+        }
+        /// <summary>
+        /// 关系类型相关
+        /// </summary>
+        public RelationTypeShell RelationTypeShell { get; private set; }
+        /// <summary>
+        /// 使用域枚举
+        /// </summary>
+        public Domain Domain { get; private set; }
+
+        #region 忽略连接点
+        public  bool IgnoredConnector(Connector connector)
+        {
+            bool ignored = true;
+            do
+            {
+                if (connector.IsLogical())
+                    break;
+                if (connector.Domain != Domain.DomainPiping)
+                    break;
+                var useElement = connector.Owner;
+                if (!(useElement is MEPCurve || connector.IsConnected))
+                {
+                    break;
+                }
+
+                ignored = InnerIgnoredConnector(connector);
+            } while (false);
+
+            return false;
+        }
+
+        private bool InnerIgnoredConnector(Connector connector)
+        {
+            bool result = false;
+            do
+            {
+                Element owner = connector.Owner;
+                #region 通用判断
+                if (owner is MEPCurve mepCurve)
+                {
+                    string typeName = mepCurve.GetSystemTypeName();
+                    result = !RelationTypeShell.IsMatchSystem(typeName);
+                    break;
+                }
+                if (SystemCalcUtil.IsStartValve(owner))
+                {
+                    result = Regex.IsMatch(connector.Description, AppSetting.SourceFlag);
+                    break;
+                }
+                #endregion
+                if (!owner.IsWaterComponment())
+                {
+                    var mepCurves = owner.GetFirstElements<MEPCurve>(connector);
+                    if (mepCurves.Any())
+                    {
+                        string typeName = (mepCurves[0] as MEPCurve).GetSystemTypeName();
+                        result = !RelationTypeShell.IsMatchSystem(typeName);
+                    }
+                    break;
+                }
+            } while (false);
+            return result;
+        }
+        #endregion
+
+        #region 元素断开点
+
+        #endregion
+    }
+}

+ 95 - 0
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/JoinElement.cs

@@ -0,0 +1,95 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:JoinElement
+ * 作者:xulisong
+ * 创建时间: 2019/2/14 14:23:10
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using SAGA.RevitUtils;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Autodesk.Revit.DB;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 连接元素
+    /// </summary>
+    public class JoinElement
+    {
+        private List<JoinItem> m_JoinItems;
+        public JoinElement(List<JoinItem> joinItems)
+        {
+            JoinItems = new ReadOnlyCollection<JoinItem>(m_JoinItems = new List<JoinItem>(joinItems));
+            Element = JoinItems.FirstOrDefault()?.BaseElement;
+            if (Element == null)
+                throw new ArgumentNullException(nameof(Element));
+            UsedRefIds = new List<int>();
+        }
+        public JoinElement(Element element)
+        {
+            Element = element;
+            JoinItems =  new ReadOnlyCollection<JoinItem>(m_JoinItems = JoinItem.GetJoinItems(element));
+            UsedRefIds = new List<int>();
+        }
+        public JoinElement(Element element,List<JoinItem> joinItems)
+        {
+            Element = element;
+            JoinItems = new ReadOnlyCollection<JoinItem>(m_JoinItems = joinItems);
+            UsedRefIds = new List<int>();
+        }
+        #region 属性相关
+        /// <summary>
+        /// 关联基础元素
+        /// </summary>
+        public Element Element { get; private set; }
+        /// <summary>
+        /// 使用过的节点,存储joinItem的referenceItem id
+        /// </summary>
+        public List<int> UsedRefIds { get; private set; }
+        /// <summary>
+        /// 关联连接项
+        /// </summary>
+        public ReadOnlyCollection<JoinItem> JoinItems { get; private set; } 
+        #endregion
+
+        #region 方法相关
+        /// <summary>
+        /// 获取当前可用连接数据
+        /// </summary>
+        /// <returns></returns>
+        private JoinItem GetCurrentItem()
+        {
+            //null判断 在前边 
+            return this.JoinItems.FirstOrDefault(ji => ji.RefElement == null || UsedRefIds.All(i => i != ji.RefElement.Id.IntegerValue));
+        }
+        /// <summary>
+        /// 获取节点,并移动到下一个获取位置
+        /// </summary>
+        /// <returns></returns>
+        public JoinItem MoveNext()
+        {
+            var item = GetCurrentItem();
+            if (item != null)
+            {
+                if (item.RefElement == null)
+                {
+                    this.m_JoinItems.RemoveAll(i => i == item);
+                }
+                else
+                {
+                    this.UsedRefIds.Add(item.RefElement.Id.IntegerValue);
+                }
+            }
+
+
+
+            return item;
+        } 
+        #endregion
+    }
+}

+ 108 - 0
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemGraphUtil.cs

@@ -0,0 +1,108 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:SystemGraphUtil
+ * 作者:xulisong
+ * 创建时间: 2019/2/14 10:28:28
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Autodesk.Revit.DB;
+using SAGA.RevitUtils;
+using SAGA.RevitUtils.Data.Graph;
+using SAGA.RevitUtils.MEP;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 系统图使用单元
+    /// </summary>
+    public static class SystemGraphUtil
+    {
+        /// <summary>
+        /// 根据起点创建系统图
+        /// </summary>
+        /// <param name="startElement"></param>
+        /// <param name="ignoredConnector">忽略的Connector</param>
+        /// <param name="breakCondition">当connector数量不满足,却又想识别成节点的元素控制</param>
+        /// <returns></returns>
+        public static SystemGraph CreateGraph(Element startElement,Predicate<Connector> ignoredConnector, Predicate<Element> breakCondition)
+        {          
+            SystemGraph graph = new SystemGraph();
+            Queue<JoinElement> joinElements = new Queue<JoinElement>();           
+            joinElements.Enqueue(CreateJoinElement(startElement, ignoredConnector, new List<int>()));
+            while (joinElements.Any())
+            {
+                var current = joinElements.Peek();
+                var joinItem = current.MoveNext();
+                if (joinItem == null)
+                {
+                    joinElements.Dequeue();
+                    continue;
+                }
+                var pathElements = joinItem.BaseElement.GetPathElements(joinItem.BaseConnector, breakCondition);
+                if (pathElements.Count < 2)
+                {
+                    continue;
+                }
+
+                #region 添加边
+                var start = pathElements[0];
+                var end = pathElements[pathElements.Count - 1];
+                var startVertex = graph.AddVertex(new SystemData(start));
+                var endVertex = graph.AddVertex(new SystemData(end));
+                var edge = graph.AddEdge(new SystemEdge(new SystemData(pathElements.GetRange(1, pathElements.Count - 2))));
+                edge.StartVertex = startVertex.Id;
+                edge.EndVertex = endVertex.Id;
+                edge = graph.AddEdge(edge);
+                #endregion
+
+                #region 延伸遍历项
+                var existJoinElement = joinElements.FirstOrDefault(j => j.Element.Id == end.Id);
+                if (existJoinElement == null)
+                {
+                    existJoinElement = CreateJoinElement(startElement, ignoredConnector, new List<int>(){ });
+                    joinElements.Enqueue(existJoinElement);
+                }
+                existJoinElement.UsedRefIds.Add(pathElements[pathElements.Count - 2].Id.IntegerValue);
+                #endregion
+
+            }
+
+            return graph;
+        }
+        #region 辅助类构建
+        public static JoinElement CreateJoinElement(Element element, Predicate<Connector> ignoredConnector, List<int> usedIds)
+        {
+            var joinItems = GetJoinItems(element, ignoredConnector, usedIds);
+            JoinElement joinElement = new JoinElement(element, joinItems);
+            return joinElement;
+        }
+
+        public static List<JoinItem> GetJoinItems(Element element, Predicate<Connector> ignoredConnector, List<int> usedIds)
+        {
+            List<JoinItem> joinItems = new List<JoinItem>();
+            var connectors = element.GetAllConnectors();
+            foreach (var connector in connectors)
+            {
+                if (ignoredConnector(connector))
+                    continue;
+                if (connector.IsConnected)
+                {
+                    foreach (Connector refConnector in connector.AllRefs)
+                    {
+                        if (refConnector.IsLogical() || refConnector.Owner.Id == element.Id || usedIds.Any(id => refConnector.Owner.Id.IntegerValue == id))
+                            continue;
+                        if (ignoredConnector(refConnector))
+                            continue;
+                        joinItems.Add(new JoinItem(connector, refConnector));
+                    }
+                }
+            }
+            return joinItems;
+        }
+
+        #endregion
+    }
+}

+ 7 - 7
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParse.cs

@@ -135,7 +135,7 @@ namespace SAGA.GplotRelationComputerManage
 
                     #region 如果是节点                 
                     var existVertex = edges.GetAvailableVertexes(v => v.IsMatch(current)).Any();
-                    if (existVertex || Setting.IsForkNode(current)||Setting.IsEquipment(current))
+                    if (existVertex || Setting.IsForkNode(current)|| MBIInfoUtil.IsEquipment(current))
                     {
                         var newVertex = new ElementsVertex(current);
                         var paths = elements.GetRange(0, i).ToList();
@@ -269,7 +269,7 @@ namespace SAGA.GplotRelationComputerManage
                 for (int j = 0; j < elements.Count; j++)
                 {
                     var currentElement = elements[j];
-                    if (Setting.IsEquipment(currentElement))
+                    if (MBIInfoUtil.IsEquipment(currentElement))
                     {
                         var tempEnd = edgeArray.AddVertex(new ElementsVertex(currentElement));
                         var tempEdge = ElementsEdge.CreateEdge(start, tempEnd, elements.GetRange(0, j));
@@ -307,7 +307,7 @@ namespace SAGA.GplotRelationComputerManage
             foreach (var vertex in originVertexes)
             {
                 var edges = edgeArray.GetEdges(vertex.Id);
-                if (edges.Count == 2 && vertex.RefData.All(e=> !Setting.IsEquipment(e)))
+                if (edges.Count == 2 && vertex.RefData.All(e=> !MBIInfoUtil.IsEquipment(e)))
                 {
                     edgeArray.DeleteVertex(vertex.Id, null);
                 }
@@ -325,7 +325,7 @@ namespace SAGA.GplotRelationComputerManage
             for (int i = 0; i < vertexes.Count; i++)
             {
                 var current = vertexes[i];
-                if (current.RefData == null && current.RefData.Any(e => Setting.IsSpecialValve(e)))
+                if (current.RefData == null && current.RefData.Any(SystemCalcUtil.IsStartValve))
                 {
                     current.SetDisableCombine(true);
                 }
@@ -348,15 +348,15 @@ namespace SAGA.GplotRelationComputerManage
                 }
                 else
                 {
-                    var equipment = elements.FirstOrDefault(e => setting.IsEquipment(e));
+                    var equipment = elements.FirstOrDefault(e => MBIInfoUtil.IsEquipment(e));
                    
                     if (equipment != null)
                     {
-                        string name = MBIInfoUtil.GetShowName(equipment);//equipment.Id + equipment.Name;
+                        string name = MBIInfoUtil.GetShowName(equipment);
                         vertex.SetEquipment(new EquipmentItem() { Name = name, Id= equipment.Id.ToString() });
                         continue;
                     }
-                    var valve = elements.FirstOrDefault(e => setting.IsSpecialValve(e));
+                    var valve = elements.FirstOrDefault(e => SystemCalcUtil.IsStartValve(e));
                     if (valve != null)
                     {
                         vertex.SetEquipment(new EquipmentItem() {IsVirtual=true, Name = valve.GetFamily().Name, Id = valve.Id.ToString() });

+ 5 - 49
MBI/SAGA.GplotRelationComputerManage/RevitSystemParse/Handler/SystemParseSetting.cs

@@ -1,13 +1,10 @@
-using Autodesk.Revit.DB;
+
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using SAGA.RevitUtils.Extends;
+using Autodesk.Revit.DB;
 using SAGA.RevitUtils.MEP;
 using SAGA.RevitUtils;
-using SAGA.MBI.Tools;
 using System.Text.RegularExpressions;
 
 namespace SAGA.GplotRelationComputerManage
@@ -17,20 +14,11 @@ namespace SAGA.GplotRelationComputerManage
     /// </summary>
     public class SystemParseSetting
     {
-        //public SystemParseSetting(GplotOptions options)
-        //{
-        //    //GplotOptions = options;
-        //    //var relationType = RelationTypeManager.GetRelationTypeItem(options.);
-        //}
         public SystemParseSetting(RelationTypeShell relationShell)
         {
             RelationTypeShell = relationShell;
             Domain = relationShell.IsPipeSystem() ? Domain.DomainPiping : Domain.DomainHvac;
         }
-        ///// <summary>
-        ///// 图相关设置
-        ///// </summary>
-        //public GplotOptions GplotOptions { get; set; }
         /// <summary>
         /// 关系类型相关
         /// </summary>
@@ -95,21 +83,6 @@ namespace SAGA.GplotRelationComputerManage
             return joinItems;
         }
 
-
-
-        /// <summary>
-        /// 标识元素是否是设备
-        /// </summary>
-        /// <param name="element"></param>
-        /// <returns></returns>
-        public bool IsEquipment(Element element)
-        {
-            if (!(element is FamilyInstance fi))
-            {
-                return false;
-            }
-            return MBIInfoUtil.IsEquipment(element);         
-        }
         /// <summary>
         /// 无用边,节点可连通
         /// </summary>
@@ -147,7 +120,7 @@ namespace SAGA.GplotRelationComputerManage
                 }
                 if (SystemCalcUtil.IsStartValve(owner))
                 {
-                    result = Regex.IsMatch(connector.Description, AppSetting.SourceFlag);// connector.Description != GplotOptions.ValveConnectorDescription;
+                    result = Regex.IsMatch(connector.Description, AppSetting.SourceFlag);
                     break;
                 } 
                 #endregion
@@ -157,30 +130,13 @@ namespace SAGA.GplotRelationComputerManage
                     if (mepCurves.Any())
                     {
                         string typeName = (mepCurves[0] as MEPCurve).GetSystemTypeName();
-                        result = !RelationTypeShell.IsMatchSystem(typeName);// !GplotOptions.MatchSystemType(typeName);
+                        result = !RelationTypeShell.IsMatchSystem(typeName);
                     }
-
                     break;
                 }
             } while (false);
             return result;
         }
-        #region 制定特殊阀门判断
-        /// <summary>
-        /// 判断制定元素是否是特定阀门
-        /// </summary>
-        /// <param name="element"></param>
-        /// <returns></returns>
-        public bool IsSpecialValve(Element element)
-        {
-            if(element is FamilyInstance fi)
-            {
-                var name = fi.GetFamily().Name;
-
-               return Regex.IsMatch(name, AppSetting.FamilyStartFlag);
-            }
-            return false;
-        } 
-        #endregion
+      
     }
 }

+ 4 - 0
MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj

@@ -137,6 +137,10 @@
     <Compile Include="RelationType\RelationTypeShell.cs" />
     <Compile Include="RevitModelPath.cs" />
     <Compile Include="RevitSystemParse\GplotOptions.cs" />
+    <Compile Include="RevitSystemParse\Handler\GplotGraphParse.cs" />
+    <Compile Include="RevitSystemParse\Handler\GplotGraphSetting.cs" />
+    <Compile Include="RevitSystemParse\Handler\JoinElement.cs" />
+    <Compile Include="RevitSystemParse\Handler\SystemGraphUtil.cs" />
     <Compile Include="RevitSystemParse\MepExtension.cs" />
     <Compile Include="RevitSystemParse\Handler\ParseQueueItem.cs" />
     <Compile Include="RevitSystemParse\Handler\SystemParse.cs" />

+ 76 - 0
MBI/SAGA.RevitUtils/Data/Graph/SystemData.cs

@@ -0,0 +1,76 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:PipeData
+ * 作者:xulisong
+ * 创建时间: 2019/2/14 9:44:51
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using Autodesk.Revit.DB;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.RevitUtils.Data.Graph
+{
+    /// <summary>
+    /// 点,边关联核心数据
+    /// </summary>
+    public class SystemData:List<Element>
+    {
+        #region 构造函数
+        public SystemData()
+        {
+
+        }
+        public SystemData(IEnumerable<Element> source):base(source)
+        {
+
+        }
+        public SystemData(Element source)
+        {
+            this.Add(source);
+        }
+        #endregion
+        #region 重写Equals
+        public override bool Equals(object obj)
+        {
+            var data = obj as SystemData;
+            if (data == null)
+                return false;
+            var flag = this.Intersect(data, new ElementEqualityComparer()).Any();
+            return flag;
+        }
+        #endregion
+
+        #region 增加元素
+
+        /// <summary>
+        /// 扩展关联数据
+        /// </summary>
+        /// <param name="elements"></param>
+        public void ExtendRefElements(List<Element> elements)
+        {
+            if (elements == null || !elements.Any())
+                return;
+            elements.ForEach(e =>
+            {
+                if (
+                    this.All(
+                        ori => e.Id.IntegerValue != ori.Id.IntegerValue))
+                {
+                    this.Add(e);
+                }
+            });
+        }
+
+        #endregion
+
+        public static implicit operator SystemData(Collection<Element> payment)
+        {
+            return new SystemData(payment);
+        }
+    }
+}

+ 27 - 0
MBI/SAGA.RevitUtils/Data/Graph/SystemEdge.cs

@@ -0,0 +1,27 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:SystemEdge
+ * 作者:xulisong
+ * 创建时间: 2019/2/14 9:46:14
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SAGA.DotNetUtils.Data;
+
+namespace SAGA.RevitUtils.Data.Graph
+{
+    public class SystemEdge:EAEdge<SystemData>
+    {
+        public SystemEdge()
+        { }
+
+        public SystemEdge(SystemData data)
+        {
+            this.Data = data;
+        }
+    }
+}

+ 33 - 0
MBI/SAGA.RevitUtils/Data/Graph/SystemGraph.cs

@@ -0,0 +1,33 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:SystemGraph
+ * 作者:xulisong
+ * 创建时间: 2019/2/14 9:46:31
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SAGA.DotNetUtils.Data;
+
+namespace SAGA.RevitUtils.Data.Graph
+{
+    /// <summary>
+    /// 系统图结构
+    /// </summary>
+    public class SystemGraph: EdgesArrayGraph<SystemVertex,SystemData,SystemEdge,SystemData>
+    {
+        public override SystemVertex AddVertex(SystemVertex vertex)
+        {
+            var existVertex = FindVertex(vertex);
+            if (existVertex != null)
+            {
+                existVertex.Merge(vertex);
+                return existVertex;
+            }
+            return base.AddVertex(vertex);
+        }
+    }
+}

+ 30 - 0
MBI/SAGA.RevitUtils/Data/Graph/SystemVertex.cs

@@ -0,0 +1,30 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:SystemVertex
+ * 作者:xulisong
+ * 创建时间: 2019/2/14 9:45:47
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SAGA.DotNetUtils.Data;
+
+namespace SAGA.RevitUtils.Data.Graph
+{
+    /// <summary>
+    /// 点信息
+    /// </summary>
+    public class SystemVertex: EAVertex<SystemData>
+    {
+        public override void Merge(EAElement<EAVertex<SystemData>> ea)
+        {
+            var sv = ea as SystemVertex;
+            if (sv == null)
+                return;
+            this.Data.ExtendRefElements(sv.Data);
+        }
+    }
+}

+ 53 - 0
MBI/SAGA.RevitUtils/MEP/MepJoinUtil.cs

@@ -129,5 +129,58 @@ namespace SAGA.RevitUtils.MEP
             sameTypeElements.RemoveAll(r => r.Id.IntegerValue == startElement.Id.IntegerValue);
             return sameTypeElements;
         }
+        /// <summary>
+        /// 获取单线Path
+        /// </summary>
+        /// <param name="startElement">起始元素</param>
+        /// <param name="startConnector">指定元素上一点</param>
+        /// <param name="breakCondition">断开约束条件</param>
+        /// <returns></returns>
+        public static List<Element> GetPathElements(this Element startElement, Connector startConnector,Predicate<Element> breakCondition)
+        {
+            /*
+             * 获取元素以指定Connector开始的Path,单点相连情况,不分叉
+             */
+            List<Element> elements = new List<Element>();
+            List<Element> useElements = new List<Element>(){startElement};
+            Connector useConnector = startConnector;
+            while (useConnector != null)
+            {
+                var joinElements = useConnector.GetJoinElements();
+                if (joinElements.Count==0||joinElements.Count > 1)
+                {
+                    break;
+                }
+                var nextElement = joinElements[0];
+                //如果原始集合中存在,如环路情况。则收尾元素相等;【理论上是只可能和第一个元素相等】
+                if (startElement.Id == nextElement.Id)
+                {
+                    useElements.Add(nextElement);
+                    break;
+                }
+                useElements.Add(nextElement);
+                if (breakCondition != null && breakCondition(nextElement))
+                {                
+                    break;
+                }
+                var connectors=nextElement.GetAllConnectors();
+                if (connectors.Count !=2)
+                {
+                    break;
+                }
+                var preElement = useConnector.Owner;
+                useConnector = null;
+                for (int i = 0; i < connectors.Count; i++)
+                {
+                    var element = connectors[i].GetReferenceConnector()?.Owner;
+                    if (element != null && element.Id != preElement.Id)
+                    {
+                        useConnector = connectors[i];
+                        break;
+                    }
+                }
+            }
+            return elements;
+        }
     }
 }

+ 4 - 0
MBI/SAGA.RevitUtils/SAGA.RevitUtils.csproj

@@ -190,6 +190,10 @@
     <Compile Include="Data\ElementsEdge.cs" />
     <Compile Include="Data\ElementsVertex.cs" />
     <Compile Include="Data\GraphNode.cs" />
+    <Compile Include="Data\Graph\SystemData.cs" />
+    <Compile Include="Data\Graph\SystemEdge.cs" />
+    <Compile Include="Data\Graph\SystemGraph.cs" />
+    <Compile Include="Data\Graph\SystemVertex.cs" />
     <Compile Include="Data\HandledMap.cs" />
     <Compile Include="Data\JoinItem.cs" />
     <Compile Include="Data\TElement.cs" />