Skip to content

feat(ifc): a duct's Pset_DuctSegmentTypeCommon.Shape, its type's shape (B43) - #686

Merged
DrunkOnJava merged 4 commits into
mainfrom
feat/b43-duct-shape
Oct 4, 2026
Merged

DrunkOnJava merged 4 commits into
mainfrom
feat/b43-duct-shape

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

B59 reads a duct type's shape from its native record's sweep profile. Each duct now also carries it in Pset_DuctSegmentTypeCommon.Shape, written the way Revit's export writes it: an IfcPropertyEnumeratedValue of IfcLabel('RECTANGULAR') on RE1's ducts. The value is IFC's PEnum_DuctSegmentShape: RECTANGULAR, ROUND or FLATOVAL. A new PropertyValue::Enumerated carries it, and the viewer's property panel shows it as text. RE1 Mechanical's 25 ducts are all rectangular, so ROUND and FLATOVAL rest on IFC's enumeration alone.

Red on draft #685 (run 37235152063, 25 of 25 missing); the output is in the test commit.


Note

Medium Risk
Touches IFC property serialization and duct export paths; incorrect enumerated encoding could break downstream BIM tools that read standard MEP property sets.

Overview
Adds PropertyValue::Enumerated so the STEP writer can emit IfcPropertyEnumeratedValue (labels as IFCLABEL), and the viewer formats those values as text rather than numeric columns.

Duct IFC export now writes Pset_DuctSegmentTypeCommon.Shape from the partition field m_duct_shape, populated when building ducts via NativeDuctShape::ifc_shape() (RECTANGULAR, ROUND, FLATOVAL). A corpus test compares all 25 RE1 Mechanical ducts against Revit’s reference IFC; CI registers duct_segment_shape.

Reviewed by Cursor Bugbot for commit 12fc679. Configure here.

… (B43)

Revit's export of RE1 Mechanical gives each of its 25 ducts
Pset_DuctSegmentTypeCommon.Shape as an IfcPropertyEnumeratedValue holding
IfcLabel('RECTANGULAR'), its type's shape. tests/duct_segment_shape.rs
requires the same enumerated value on each duct in rvt-rs's export.

Red on main (draft #685, run 37235152063, "Corpus health (tier 2)"):

  panicked at tests/duct_segment_shape.rs:131:5:
  25 of 25 ducts' Shape is not Revit's (Tag, Revit's, rvt-rs's), first 3: [("428274", Some(("IFCPROPERTYENUMERATEDVALUE", "(IFCLABEL('RECTANGULAR'))")), None), ("435015", Some(("IFCPROPERTYENUMERATEDVALUE", "(IFCLABEL('RECTANGULAR'))")), None), ("435175", Some(("IFCPROPERTYENUMERATEDVALUE", "(IFCLABEL('RECTANGULAR'))")), None)]
…e (B43)

B59 reads a duct type's shape from its native record's sweep profile. Each
duct now also carries it in Pset_DuctSegmentTypeCommon.Shape as IFC's
PEnum_DuctSegmentShape names it (RECTANGULAR, ROUND, FLATOVAL), written as
an IfcPropertyEnumeratedValue of IfcLabels as Revit's export writes it: a
new PropertyValue::Enumerated, which the viewer's property panel shows as
text. RE1 Mechanical's 25 ducts are rectangular; the round and oval values
follow IFC's enumeration, since no reference export holds such a duct.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Shape omitted without duct length
    • Pset_DuctSegmentTypeCommon is now emitted when either Length or Shape is present, so shaped ducts without recovered segment length still export Shape.

Create PR

Or push these changes by commenting:

@cursor push 7ef2aace80
Preview (7ef2aace80)
diff --git a/src/ifc/export_content.rs b/src/ifc/export_content.rs
--- a/src/ifc/export_content.rs
+++ b/src/ifc/export_content.rs
@@ -766,9 +766,6 @@
                 },
             });
         }
-        // A duct's length is also in its Pset_DuctSegmentTypeCommon, as on
-        // every RE1 Mechanical duct.
-        let duct_set = (decoded.class == "Duct").then_some("Pset_DuctSegmentTypeCommon");
         let duct_shape = decoded.fields.iter().find_map(|(name, value)| match value {
             InstanceField::String(shape)
                 if name == crate::partition_schema_mvp::DUCT_SHAPE_FIELD =>
@@ -785,8 +782,7 @@
             _ => None,
         };
         if let Some(length) = segment_length {
-            let sets = ["Pset_FlowSegmentPipeSegment", "Pset_FlowSegmentDuctSegment"];
-            for name in sets.into_iter().chain(duct_set) {
+            for name in ["Pset_FlowSegmentPipeSegment", "Pset_FlowSegmentDuctSegment"] {
                 let mut properties = vec![Property {
                     name: "Length".into(),
                     value: PropertyValue::PositiveLengthFeet(length),
@@ -797,13 +793,6 @@
                         value: PropertyValue::LengthFeet(height),
                     });
                 }
-                // B43: a duct's shape, its type's, as Revit's export gives it.
-                if let (Some(shape), "Pset_DuctSegmentTypeCommon") = (duct_shape.as_ref(), name) {
-                    properties.push(Property {
-                        name: "Shape".into(),
-                        value: PropertyValue::Enumerated(vec![shape.clone()]),
-                    });
-                }
                 entities.push(entities::IfcEntity::ElementPropertySet {
                     element: entity_index,
                     set: PropertySet {
@@ -813,6 +802,32 @@
                 });
             }
         }
+        // A duct's length and shape are independent in Pset_DuctSegmentTypeCommon
+        // (RE-134 length, B43 shape); emit the set when either is present.
+        if decoded.class == "Duct" {
+            let mut properties = Vec::new();
+            if let Some(length) = segment_length {
+                properties.push(Property {
+                    name: "Length".into(),
+                    value: PropertyValue::PositiveLengthFeet(length),
+                });
+            }
+            if let Some(shape) = duct_shape {
+                properties.push(Property {
+                    name: "Shape".into(),
+                    value: PropertyValue::Enumerated(vec![shape]),
+                });
+            }
+            if !properties.is_empty() {
+                entities.push(entities::IfcEntity::ElementPropertySet {
+                    element: entity_index,
+                    set: PropertySet {
+                        name: "Pset_DuctSegmentTypeCommon".into(),
+                        properties,
+                    },
+                });
+            }
+        }
         // RE-154: the common property sets' Reference, the type's name;
         // RE-156: the shared parameter Serial Number.
         for set in reference_sets.into_iter().chain(serial_sets) {

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 12fc679. Configure here.

Comment thread src/ifc/export_content.rs Resolved
Bugbot on #686: Shape went into Pset_DuctSegmentTypeCommon only inside the
length branch, so a duct whose length was not recovered (one not along a
model axis, for instance) lost its shape too. The set is now built on its
own, with Length and Shape each where known, in the same order as before.
@DrunkOnJava
DrunkOnJava merged commit c4063a9 into main Oct 4, 2026
24 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/b43-duct-shape branch October 4, 2026 21:51
DrunkOnJava added a commit that referenced this pull request Nov 9, 2026
…s an enumerated or list value (#1524) (#1590)

## Summary

`tools/re/bodies_across_saves.py` skips a property that holds no single
value instead of raising on it, so the same-project gate can judge an
export in which a product carries an enumerated or list property.

## Motivation

Measure run
[42585494298](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42585494298)
on #1524 failed `Same-project gates` for the six `rme_advanced` and
`rme_basic` saves of 2025, 2026 and 2027. Each one's
`bodies_across_saves.txt` holds a traceback in place of its result:
`AttributeError: entity instance of type
'IFC4.IfcPropertyEnumeratedValue' has no attribute 'NominalValue'`, from
`properties`. The other nine samples (`rac_advanced`, `rac_basic`,
`rst_basic`, each of 2025 to 2027) passed.

#1524 types the 724 and 728 ducts of those samples, and a typed duct
carries `Pset_DuctSegmentTypeCommon.Shape`, which the writer emits as an
`IfcPropertyEnumeratedValue` (#686). `properties` read
`prop.NominalValue` on every property of every product it compares, and
an enumerated or list value has none. No export the check had read held
one before: the same six saves passed in run
[42583038481](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42583038481)
on #1587's head, whose exports type no duct there.

## Changes

- `tools/re/bodies_across_saves.py`: `properties` reads `NominalValue`
with `getattr(prop, "NominalValue", None)` and skips a property without
one, as it already skipped one whose `NominalValue` is `None`.
`placement_source` reads it the same way (it tested the property's name
first, so it was not reached for a Shape, but it had the same pattern).

## Testing

Unit tests: N/A. The check is the scorer run on the exports that tripped
it.

- **The six exports that failed**, from the `keep_ifc` run
[42585486357](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42585486357)
of #1524's head, through this branch's scorer with each save held to the
2024 and 2025 saves as Measure holds it: all six print `bodies across
saves: PASS` and exit 0, with their ports, cut openings, door and window
sizes, properties and census lines compared against the 2025 save (for
example `rme_advanced` 2026: ports 7,276 of 7,276 the same, properties
5,158 equal and none different, census 6,605 bodies the same). The same
scorer from `main` raises the `AttributeError` on all six, as the run's
own files show.
- **The Measure with this branch as its scorers' ref** is dispatched on
#1524's head next; its `same-project gates` verdict is the check on that
pull request.

## Audit-honesty checklist

- [x] The gate still fails on a real difference: only the read of a
property without a single value changed; every comparison after it is as
before.
- [x] No emojis, private paths or PII.

## Legal and contribution hygiene

- [x] Apache-2.0. No Autodesk source, internals or NDA material.

## Breaking changes

None.
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