Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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