Connectors

Connectors

As shown in the previous section, new pipes and ducts can be created between two 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(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.EndConn ||
                                                connected.ConnectorType == ConnectorType.CurveConn ||
                                                connected.ConnectorType == ConnectorType.PhysicalConn)
                                        {
                                                message += "\nConnector is connected to: " + connected.Owner.Name;
                                                message += "\nConnection type is: " + connected.ConnectorType;
                                        }
                                }
                        }
                }
                else
                {
                        message += "\nConnector is not connected to anything.";
                }
                
                MessageBox.Show(message, "Revit");            
        }
}

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

Figure 168: Connector Information