Skip to content

feat(native): an element's joins are read from its family instances' native connectors (B86, RE-171) - #716

Merged
DrunkOnJava merged 5 commits into
mainfrom
feat/b86-native-joins
Oct 5, 2026
Merged

DrunkOnJava merged 5 commits into
mainfrom
feat/b86-native-joins

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

B86, the rest of B54 (#528): the 13 joins of Revit's RE1 export that rvt-rs did not read.

Red. tests/mep_connections.rs requires every join Revit's export writes between two elements rvt-rs writes with ports, and no join rvt-rs writes between two elements Revit holds that is not Revit's. On draft #707 (Corpus health run 37302264599) it failed with Plumbing 6 of 126 not written and Mechanical 7 of 73. That red result was in hand before the native implementation below was written. The proxy-filter commit was written while that run was still going.

What reads the joins. A FamilyInstance record holds a Connector object per connector. Each one gives its index (m_nIndex) and lists, in m_arrRefs, the elements joined to it with their connector indices and a connection type. RE-171's probe (run 37303312731) scored the type-1 references against Revit's exports:

model Revit's joins native type-1 references not Revit's
RE1 Mechanical 73 73 0
RE1 Plumbing 126 126 2 (both on tank 442378, which Revit's export leaves out, RE-169)

native_connectors::family_instance_joins reads them from the MEP categories' family instances, selected by id. The export uses them wherever the native record path reads the file (Revit 2023 to 2027). The byte-form lists (RE-138, RE-141) remain the fallback on 2025, the one release they are measured on. Joins whose other end is a proxy are now written, because proxies carry ports since B83.

Why not widen the byte form. A side agent pointed out that the alternative, accepting lists with any terminal or equipment first, found anywhere, with indices up to 31, would be matched on bytes alone, and only RE1 could catch a false match. On Autodesk's 2025 MEP samples that version added 252 and 249 joins. The native connectors there hold 2,609 and 2,652. The byte form disagrees with them in two ways (runs 37303169279, 37306537328):

  • Duct ends. 207 of main's 265 joins that native lacks are the same two elements joined at the other end of the duct. That is the earlier-copy inversion rule, measured on RE1 only, misreading the samples.
  • Impossible joins. Main joins 11 and 12 duct or pipe ends twice, which cannot happen. Native joins none twice, on every file.

Measure (run 37306537328, head 55a6830 against main plus the join-list probe):

  • RE1. Mechanical 73 of 73 and Plumbing 126 of 126 joins written. The only two not in Revit's export are the tank's. No port is untied, and there are no schema findings.
  • Samples. The 2024, 2025 and 2026 MEP samples each write 2,609 (rme_advanced) and 2,652 (rme_basic) joins, the same project in three releases. 2024 and 2026 wrote none before.
  • Unchanged. Every other model's and sample's output is identical.
  • Timing (one runner). Core Interior, Einhoven, the architecture samples and 2027 read 0.93 to 1.03. The MEP samples read 1.06 to 1.16, because they now decode their MEP instances' records and write about 2,600 more joins each.

The probes examples/probe_re171_connector_refs.rs and examples/probe_re170_join_list.rs, and the RE-170 and RE-171 report, follow in their own research pull request.


Note

Medium Risk
Changes how MEP joins are discovered and which IFC port connections are emitted, with broad impact on MEP exports but a version fallback and new regression test against Revit reference exports.

Overview
MEP connector joins are now taken primarily from native FamilyInstance connector references (type-1 m_arrRefs entries) via native_connectors::family_instance_joins, scoped to 18 MEP equipment/terminal classes so full-model furniture decode is avoided. When native records are unavailable, the existing byte-form partition_connector_pairs scans remain the fallback on supported Revit versions.

Decoded join fields are attached to any element that has pairs, not only ducts, pipes, and fittings—so terminals, equipment, and similar instances participate in export.

IFC IfcRelConnectsPorts emission treats IfcBuildingElementProxy as port-bearing alongside distribution elements, so joins involving proxies (e.g. mechanical AHU to ducts) are written when both ends export with ports.

A new mep_connections corpus test compares port-to-port joins in rvt-rs STEP output against Revit’s reference IFC for RE1 Electrical, Plumbing, and Mechanical; CI includes this target.

Reviewed by Cursor Bugbot for commit dc2771c. Configure here.

… (B86)

Revit's export of the RE1 MEP models writes each join as an
IfcRelConnectsPorts between two ports named after their elements and
indices. Wherever rvt-rs writes both elements of one of Revit's joins with
ports (distribution elements, and proxies since B83), it must write that
join; and a join it writes between two elements Revit's export holds must be
one of Revit's. These are B54's 13 connections not read.

Red on draft #707 (on top of B83), Corpus health run 37302264599:

    RE1-Electrical.rvt: 0 of Revit's 0 joins between elements with ports written, 0 written that are not Revit's
    RE1-Plumbing.rvt: 120 of Revit's 126 joins between elements with ports written, 0 written that are not Revit's
    RE1-Mechanical.rvt: 66 of Revit's 73 joins between elements with ports written, 0 written that are not Revit's
    thread 'every_join_revit_writes_is_written' (6093) panicked at tests/mep_connections.rs:184:5:
    RE1-Plumbing.rvt: 6 of Revit's 126 joins between elements rvt-rs writes with ports are not written: [[(442581, 1), (444719, 0)], [(442625, 1), (445170, 0)], [(443223, 1), (445078, 0)], [(443279, 1), (445109, 0)], [(443513, 1), (445208, 0)], [(446093, 2), (447241, 0)]]
    RE1-Mechanical.rvt: 7 of Revit's 73 joins between elements rvt-rs writes with ports are not written: [[(427568, 6), (441892, 0)], [(427568, 7), (441849, 0)], [(427568, 9), (428274, 0)], [(427568, 10), (438792, 0)], [(427568, 11), (441731, 0)], [(433643, 1), (491631, 1)], [(433747, 1), (490317, 1)]]
    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.63s
A join (RE-138, RE-141) was written only between two distribution elements,
the only elements IfcRelConnectsPortToElement may tie a port to. Since B83 a
proxy's ports are nested in it, so a join with a proxy at one end is written
too: Revit's export of RE1 Mechanical joins its air handling unit (427568)
to five ducts and pipes.
…native connectors (B86, RE-171)

A FamilyInstance record holds a Connector object per connector: its index in
m_nIndex and, in m_arrRefs, the elements joined to it with their connector
indices and a connection type. RE-171's probe (Measure run 37303312731)
scored the type-1 references against Revit's exports: RE1 Mechanical 73 of
73 joins and RE1 Plumbing 126 of 126, with nothing else but the two of tank
442378, which Revit's export leaves out. The byte-form lists (RE-138, RE-141)
found 66 and 120 of them.

native_connectors::family_instance_joins reads them, and the export attaches
them wherever the native record path reads the file (Revit 2023 to 2027);
the list form stays the fallback on 2025, the one release it is measured on.
A side agent's note on widening the list form instead (lists with any
terminal or equipment first, found anywhere, connector indices to 31): it
would be matched by bytes alone with only RE1 to score it, and it found 252
and 249 more joins on Autodesk's 2025 MEP samples where their native
connectors hold about 4,900 each (runs 37303169279, 37303312731).

The red test (Corpus health run 37302264599) was in hand before this was
written.
…joins (B86)

Reading every family instance's record cost a second on Core Interior
(1.42 of main's time) and on Autodesk's 2027 MEP samples (1.7 to 1.9),
whose furniture and casework hold no connectors (run 37304618502). The
joins are read from the instances of the MEP categories, selected by id,
and a file with none skips the native pass.
@DrunkOnJava
DrunkOnJava merged commit dcb1fab into main Oct 5, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/b86-native-joins branch October 5, 2026 13:09
DrunkOnJava added a commit that referenced this pull request Oct 5, 2026
… that hold every join (RE-171) (#717)

Research behind B86 (#716).

- **RE-170** (`examples/probe_re170_unread_joins.rs`, run 37301472228)
finds B54's ten unread joins on RE1. Each is a list in RE-138's form
with the terminal or equipment first, which the reader never looked for.
- **RE-171** (`examples/probe_re171_connector_refs.rs`, run 37303312731)
reads joins from a family instance's `Connector` objects: the own index
is `m_nIndex`, and the joins are the type-1 references in `m_arrRefs`.
- On RE1 they give Revit's 73 joins on Mechanical and 126 on Plumbing.
The only extras are the two on the tank Revit leaves out.
- On Autodesk's 2025 MEP samples the list form disagrees with them. 207
of its 265 extra joins on `rme_advanced` put the duct's end the other
way round, and it joins 11 duct and pipe ends twice. The connectors join
no end twice.
- `examples/probe_re170_join_list.rs` prints every join an export
writes, one per line, for diffing two refs on files Revit has not
exported.

The two reports are in `reports/element-framing/`.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> New Cargo examples and markdown reports only; no library or export
behavior changes in this PR.
> 
> **Overview**
> Adds **research probes and write-ups** for MEP port joins (#528,
B54/B86), without changing export logic in this diff.
> 
> **RE-170** adds `probe_re170_unread_joins` to compare Revit’s
`MODEL.ifc` `IfcRelConnectsPorts` against the rvt-rs export, then scan
partition bytes for RE-138-style join lists that name missing
connections (including lists with **terminals/equipment first**, which
RE-138/RE-141 never matched). `probe_re170_join_list` prints every join
the export writes, one sorted line per `IfcRelConnectsPorts`, for
ref-to-ref diffs when there is no Revit IFC baseline.
> 
> **RE-171** adds `probe_re171_connector_refs`, which walks native
`FamilyInstance` / curve records, reads each `Connector`’s type-1
`m_arrRefs`, and scores candidate own-index fields (notably
**`m_nIndex`**) against Revit’s IFC joins.
> 
> The reports in `reports/element-framing/` capture the conclusions: the
ten RE1 gaps live in list form but widening list scanning would add
hundreds of false joins on Autodesk samples; **native connector refs**
match Revit on RE1 and motivate B86 reading records instead of lists.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
2c1fd67. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant