[Revit Api] – Elements connected to a Hub

Internally Revit utilizes a mechanism called “Hub” to connect analytical elements to each other. So lets say you need to find members which are connected to a given analytical node; first you need to find out the Hub in which the node is contained and than query that Hub to extract the other connected elements. The connection and connector procedure is somewhat complicated but here is a sample method:

        private void getConnected(Document doc, ElementId nodeId)
        {
            Element element = doc.GetElement(nodeId);
            ElementId joinedId;
            ElementId hubId = ((ReferencePoint)element).GetHubId();
            Hub nodeHub = (Hub)doc.GetElement(hubId);
            List<ElementId> connected = new List<ElementId>();

            ConnectorSet ConnectorManager1 = nodeHub.GetHubConnectorManager().Connectors;
            foreach (Connector connector in ConnectorManager1)
            {
                foreach (Connector joinedRef in connector.AllRefs)
                {
                    joinedId = joinedRef.Owner.Id;
                    connected.Add(joinedId);
                }
            }
        }

Leave a Comment

You must be logged in to post a comment.

Thanks for downloading!

Top