Connectors

Connectors are associated with a domain - ducts, piping or electrical - which is obtained from the Domain property of a Connector. Connectors are present on mechanical equipment as well as on ducts and pipes.

To traverse a system, you can examine connectors on the base equipment of the system and determine what is attached to the connector by checking the IsConnected property and then the AllRefs property. When looking for a physical connection, it is important to check the ConnectionType of the connector. There are both physical and logical connectors in Revit, but only the physical connectors are visible in the application. The following imagine shows the two types of physical connectors - end connections and curve connectors.

Figure 167: Physical connectors

The following sample shows how to determine the owner of a connector, and what, if anything it attaches to, along with the connection type.

Code Region 30-5: Determine what is attached to a connector

public void GetElementAtConnector(Autodesk.Revit.DB.Connector connector)
{
    MEPSystem mepSystem = connector.MEPSystem;
    if (null != mepSystem)
    {
        string message = "Connector is owned by: " + connector.Owner.Name;
                
        if (connector.IsConnected == true)
        {
            ConnectorSet connectorSet = connector.AllRefs;
            ConnectorSetIterator csi = connectorSet.ForwardIterator();
            while (csi.MoveNext())
            {
                Connector connected = csi.Current as Connector;
                if (null != connected)
                {
                    // look for physical connections
                    if (connected.ConnectorType == ConnectorType.End ||
                        connected.ConnectorType == ConnectorType.Curve ||
                        connected.ConnectorType == ConnectorType.Physical)
                    {
                        message += "\nConnector is connected to: " + connected.Owner.Name;
                        message += "\nConnection type is: " + connected.ConnectorType;
                    }
                }
            }
        }
        else
        {
            message += "\nConnector is not connected to anything.";
        }

        TaskDialog.Show("Revit", message);            
    }
}

The following dialog box is the result of running this code example on the connector from a piece of plumbing equipment.

Figure 168: Connector Information