Hub class, as the Revit API chm file states, represents a connection between two or more Autodesk Revit Elements. So rather than connecting the two elements directly, the connection is created between two Hubs. Elements connected via a Hub do not refer directly to each other - they each refer to the Hub that keeps all the connectivity information. And the class is contained in the Autodesk.Revit.DB.Structure namespace.
To access the element Ids of the elements that are connected to a Hub, the approach is to use the connectors using the ConnectorManager from a given Hub and then use the AllRefs to get access to all the connected connectors and use the Owner property on each of the linked/joined connectors to get access to the elements that are connected. The code snippet illustrates this approach.
public class Command : IExternalCommand
public Result Execute(ExternalCommandData commandData,
ref string message,
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
FilteredElementCollector coll = new FilteredElementCollector(doc);
String str = String.Empty;
foreach (Autodesk.Revit.DB.Structure.Hub hub
if (null != hub)
ConnectorManager mgr = hub.GetHubConnectorManager();
foreach (Connector conn in mgr.Connectors)
ConnectorSet joinedConnectors = conn.AllRefs;
foreach (Connector joinedConn in joinedConnectors)
str = str + "Hub (Id) "
+ " is connected to Element (Id) "
TaskDialog.Show("Hub connection details", str);
The output of the code: