Skip to content

MEP connectivity: ports and port-to-port connections (IfcDistributionPort, IfcRelConnectsPortToElement, IfcRelConnectsPorts) #528

Closed

Description

@DrunkOnJava

Problem

Revit's own IFC export of an MEP model carries its connectivity: one IfcDistributionPort per connector (named InPort_<ElementId>_<index> or OutPort_<ElementId>_<index>, flow direction .SINK. or .SOURCE., with a placement), an IfcRelConnectsPortToElement for each, an IfcRelConnectsPorts for each connected pair, and an IfcSystem per system. On the MIT RE1 models:

model ports port-to-element port-to-port systems
RE1 Mechanical 150 150 73 5
RE1 Plumbing 260 260 126 8
RE1 Electrical 53 53 0 13

rvt-rs writes none of them: its MEP elements are unconnected shapes.

What is known

  • A pipe's or duct's connector entries (RE-131) hold each end's point, keyed by the element connected there and its connector index.
  • The curve's own object lists its connectors' references (its own ElementId, then the element joined at that connector and that element's connector index) about 1,060 bytes after its RbsCurveConnectorManager anchor (RE-134). This is seen, not decoded.
  • A fitting's, terminal's or piece of equipment's connectors are defined in its family, which rvt-rs does not read.

Acceptance

Ports and connections written for the elements whose connectors are decoded, with per-model counts against Revit's export on the reference pack (#407), the shortfall named. A connection is written only when both of its ports are, so a pipe joined to an undecoded fitting stays unconnected rather than dangling.

Related

#96, RE-131, RE-134.

Activity

  1. added
    area:elements
    area:ifc
    priority:P3
    type:feature
    on Sep 30, 2026
  2. DrunkOnJava commented on Oct 1, 2026

    @DrunkOnJava
    OwnerAuthor

    First part delivered in #550 (RE-138, reports/element-framing/RE-138-connector-pairs.md), measured on the runners (Measure run 36874925630).

    • Decoded: a duct's or pipe's object lists its joins as counted lists of two references after the RbsCurveConnectorManager anchor, in two blocks that store the curve's own connector index differently (inverted in the earlier). The lists reproduce 94.3% (50 of 53) of Revit's connections that involve a duct or pipe on RE1 Mechanical and 94.4% (102 of 108) on Plumbing.
    • Written: IfcDistributionPort, IfcRelConnectsPortToElement and IfcRelConnectsPorts for each join whose two elements are exported as distribution elements: 53 of 59 (89.8%) on Mechanical and 112 of 118 (94.9%) on Plumbing, every port tied to the element its name gives, IfcOpenShell's IFC4 schema validation of both files clean. Core Interior's export is byte-identical and no other scorer changes. tools/re/ports_vs_ifc.py is in every Measure run.

    Still open on this issue:

    • Flow direction. Revit names ports InPort_/OutPort_ with .SINK./.SOURCE. (they agree on all 134 named ports of Mechanical), and the same connector index is In on some pipes and Out on others, so it is the system's flow, which the lists do not carry. rvt-rs writes .NOTDEFINED. and names ports Port_<ElementId>_<index>.
    • Connections that involve no duct or pipe (fitting to fitting, fitting to equipment): 14 of Mechanical's 73 and 8 of Plumbing's 126 involve no IfcFlowSegment. Only the lists of ducts and pipes have been looked at.
    • Equipment ports. Equipment rvt-rs writes as an IfcBuildingElementProxy gets none (IFC4 allows a port on a distribution element only); Revit's IFC2X3 export has 5 such ports on Mechanical.
    • The 6 connections not written on each model. On Mechanical, 3 are not read and 3 are to equipment written as a proxy; on Plumbing all 6 are not read. What is different about the lists of those is not established.
    • Port placement: no ObjectPlacement yet.
  3. DrunkOnJava commented on Oct 1, 2026

    @DrunkOnJava
    OwnerAuthor

    RE-141 (PR #552, reports/element-framing/RE-141-fitting-joins.md): the fittings' own joins are read, and the export writes ports for them, fitting to fitting included.

    • A fitting's own record holds only the ascending ids it refers to, with no connector index, and the pipes' connector managers lie outside the partition's leading record chain (all 63 on RE1 Plumbing and 31 on Mechanical). So the fittings' joins were not where RE-138's lead looked.
    • They are in the same list form as a pipe's (u32 2, then two references of element, connector index and u32 1), with the fitting first, found by the list alone anywhere in a partition. A fitting's list is written once and its own connector index is Revit's; a pipe's earlier copy is inverted.
    • Against Revit's own export of the RE1 models, every connection that involves a fitting is read on Plumbing (99 of 99, indexes exact) and 60 of 62 on Mechanical.
    • Export, head against main on the Measure workflow: of all of Revit's port-to-port connections, 66 of 73 are written on Mechanical (53 before) and 120 of 126 on Plumbing (112 before), none and one that Revit does not hold, no IfcOpenShell schema finding, and the other four RE1 and Core Interior outputs are byte-identical.

    Still open on this issue: flow direction (the lists carry none), port placement, and the 7 and 6 connections left, which are joins to equipment written as a proxy (IFC4 allows no port on one) and joins no list read gives.

  4. 10 remaining items

  5. DrunkOnJava commented on Oct 3, 2026

    @DrunkOnJava
    OwnerAuthor

    MEP systems landed in #631, from RE-162 (#632).

    • Where they are stored. Each system is one data object of class RbsHvacSystem, RbsPipingSystem or RbsElectricalSystem. Its members are the elements whose own data objects hold its id. HVAC and piping systems are named by the object's first ASCII string. Electrical systems are named by their circuit number, and an empty number is Revit's <unnamed>.
    • What rvt-rs writes. One IfcSystem per system, its members grouped by IfcRelAssignsToGroup and the building served by IfcRelServicesBuildings.
    • Tested against Revit's own export. tests/mep_systems.rs compares rvt-rs's export of RE1 Mechanical, Plumbing and Electrical with Revit's IFC4 export. All 26 systems match by name and member set (5, 8 and 13), CI run 37149305337: test re1_mep_systems_are_revits ... ok.

    Ports and connections were written earlier (#550, #552). What is still open here is flow direction, the .SINK./.SOURCE. of each port, which RE-138 found no stored field for, and the few connections not yet read (7 of 73 on Mechanical, 6 of 126 on Plumbing).

  6. DrunkOnJava commented on Oct 4, 2026

    @DrunkOnJava
    OwnerAuthor

    Progress, 2026-10-04 (#673, B54): every duct and pipe now has a port at each end, joined or not. Revit's export writes connectors 0 and 1 of 92 of RE1's 94 ducts and pipes as ports whether or not anything is connected. rvt-rs wrote a port only for a join it read. With both end ports written, RE1 Plumbing has 255 ports against Revit's 260 (from 242) and every duct and pipe end port Revit writes on Mechanical and Plumbing is in the file, checked by tests/duct_and_pipe_ports.rs. One port is extra: port 0 of pipe 444124, which is joined to the tank Revit's export leaves out.

    Next: a family instance's own connectors. Its FamilySymbol's native record lists them (m_arrConnectorData, each with an m_index), and its Family has a ConnectorDataCell per index with its domain. That is where Electrical's 53 ports and the open ports of fixtures and fittings should come from. It is being measured against Revit's port indices now.

  7. DrunkOnJava commented on Oct 19, 2026

    @DrunkOnJava
    OwnerAuthor

    The acceptance here is met. Ports and connections are written for every element whose connectors are decoded, measured against Revit's own exports (Measure run 39261416282):

    What is left is tracked on its own: an HVAC or piping connector's flow direction, every port's SystemType and a connector's description in #834, and the ports' placement, which Revit's export gives each port and rvt-rs does not yet, in #847.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:elementsarea:ifcpriority:P3type:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions