Created
June 3, 2021 10:18
-
-
Save chuongmep/4e46e7b6c89594ffb7ea09ddff047c9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<Element> GetElementConnectedWith(this Element e) | |
{ | |
List<Element> elements = new List<Element>(); | |
List<Connector> connectors = e.GetConnectors(); | |
if (connectors == null) return elements; | |
if (connectors.Count == 0) return elements; | |
elements = GetElementConnectedWith(connectors); | |
return elements; | |
} | |
public static List<Element> GetElementConnectedWith(this List<Connector> connectors) | |
{ | |
List<Element> elements = new List<Element>(); | |
foreach (Connector connector in connectors) | |
{ | |
if (connector.IsConnected) | |
{ | |
List<Element> nextElement = connector.GetElementsConnected(); | |
nextElement.ForEach(delegate (Element ele) { elements.Add(ele); }); | |
} | |
} | |
return elements; | |
} | |
public static List<Element> GetElementsConnected(this Connector conn) | |
{ | |
List<Element> elements = new List<Element>(); | |
ConnectorSetIterator connectorSetIterator = conn.AllRefs.ForwardIterator(); | |
while (connectorSetIterator.MoveNext()) | |
{ | |
Connector connref = connectorSetIterator.Current as Connector; | |
Element elem = connref.Owner; | |
if (elem != null) | |
{ | |
elements.Add(elem); | |
} | |
} | |
return elements; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment