Connector Class


A connector in an Autodesk Revit MEP project document.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)

Syntax

C#
public class Connector : IConnector, IDisposable
Visual Basic
Public Class Connector _
	Implements IConnector, IDisposable
Visual C++
public ref class Connector : IConnector, 
	IDisposable

Remarks

This connector is an item that is a part of another element (duct, pipe, fitting, or equipment etc.). This connector does not represent the connector element that can be created inside a family; for that element, refer to ConnectorElement .

Examples

Copy C#
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);            
    }
}
Copy VB.NET
Public Sub GetElementAtConnector(connector As Autodesk.Revit.DB.Connector)
    Dim mepSystem As MEPSystem = connector.MEPSystem
    If mepSystem IsNot Nothing Then
        Dim message As String = "Connector is owned by: " & Convert.ToString(connector.Owner.Name)

        If connector.IsConnected = True Then
            Dim connectorSet As ConnectorSet = connector.AllRefs
            Dim csi As ConnectorSetIterator = connectorSet.ForwardIterator()
            While csi.MoveNext()
                Dim connected As Connector = TryCast(csi.Current, Connector)
                If connected IsNot Nothing Then
                    ' look for physical connections
                    If connected.ConnectorType = ConnectorType.[End] OrElse connected.ConnectorType = ConnectorType.Curve OrElse connected.ConnectorType = ConnectorType.Physical Then
                        message += vbLf & "Connector is connected to: " + connected.Owner.Name
                        message += vbLf & "Connection type is: " + connected.ConnectorType
                    End If
                End If
            End While
        Else
            message += vbLf & "Connector is not connected to anything."
        End If

        TaskDialog.Show("Revit", message)
    End If
End Sub

Inheritance Hierarchy

System Object
Autodesk.Revit.DB Connector

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →