Skip to content

fix(ifc): a material's colour reaches IFC viewers through an IfcMaterialDefinitionRepresentation - #1940

Merged
DrunkOnJava merged 4 commits into
mainfrom
fix/material-colour-reaches-ifc
Nov 13, 2026
Merged

DrunkOnJava merged 4 commits into
mainfrom
fix/material-colour-reaches-ifc

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Every coloured material's surface style was written as an IfcStyledItem with no Item, outside any representation. IFC4 allows an IfcStyledItem with no Item only inside an IfcStyledRepresentation of an IfcMaterialDefinitionRepresentation, which is how a material carries its surface style. None was written, so no IFC viewer could tie the colour to the material or to an element. Each coloured material now gets IFCSTYLEDREPRESENTATION(#context,'Style','Material',(#styled_item)) and IFCMATERIALDEFINITIONREPRESENTATION($,$,(#styled_representation),#material).

Motivation

Found by the batch 9 export audit: a DeepSeek checker's lead, re-read against the code by Claude. src/ifc/step_writer.rs emitted the colour and rendering entities with no path to the material. The glTF export already carries the colours, so only IFC consumers missed them.

Changes

  • src/ifc/step_writer.rs: two entities per coloured material, and the comment that described them.
  • changelog.d/fixed/material-colour-reaches-viewers.md.

Testing

The unfiltered Measure against main is in this PR's comments, and should show:

  • every export with a coloured material moving by the two new entity types;
  • no element entity moving;
  • the colour scorers unchanged (material_colours_vs_ifc and glb_material_colours_vs_ifc find surface styles by name).

The IfcOpenShell validator and schema jobs check the new entities against the IFC4 schema. Core Interior's witness observations count entities, so they are refreshed from CI's artifact if they drift.

Audit-honesty checklist

  • README / docs reflect the current state after this PR
  • A user-visible change has its entry as a fragment under changelog.d/fixed/

…ialDefinitionRepresentation

Each coloured material's IfcStyledItem was written with no Item, outside any
representation, so nothing tied the colour to the material or to any
element. It now sits in an IfcStyledRepresentation ('Style', 'Material') of
an IfcMaterialDefinitionRepresentation naming the material, the IFC4
mechanism viewers read for a material's surface style.
…tion and styled representations (Measure 43511650641)
@DrunkOnJava

Copy link
Copy Markdown
Owner Author

Measure 43511650641: an unfiltered run against main b817ac6, with every model and scorer and the samples. The head is 7349e57.

  • Exports: all 101 change, by the two new entity types alone: each coloured material gains an IFCSTYLEDREPRESENTATION and an IFCMATERIALDEFINITIONREPRESENTATION.
  • diagnostics.json: all 101 are equal.
  • Scorers: none moves. The only scorer difference is Core Interior's witness counts (+86 of each new entity). The colour scorers (material_colours_vs_ifc, glb_material_colours_vs_ifc) read surface styles by name and are unchanged.
  • Same-project gates: pass.
  • Witness: Core Interior's observations are refreshed from Measure's witness files. The replay passes for ifc-lite, ifcopenshell and rvt-rs on both artifacts (slim surface 14 fields, 0 diffs).

The IFC4 schema validation of the new entities is CI's IfcOpenShell job, which runs now that the PR is ready.

@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 13, 2026 22:10
# Conflicts:
#	research/witness/magnetar-2024-core-interior-slim/observations/rvt-rs.json
#	research/witness/magnetar-2024-core-interior/observations/rvt-rs.json
…1939's quantities and this change's material representations (Measure 43520712633)
@DrunkOnJava
DrunkOnJava merged commit 6ad5efa into main Nov 13, 2026
36 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/material-colour-reaches-ifc branch November 13, 2026 23:11
DrunkOnJava added a commit that referenced this pull request Nov 13, 2026
…r --revit-property-sets, and docs and messages that say what the export does (batch 9) (#1946)

## Summary

Batch 9's confirmed findings that change no IFC value, each re-read
against the code by Claude:

- **One material rule.** The viewer's schedule
(`scene_graph::build_schedule`) read only an element's single material,
so a layered wall showed none where the elements CSV names its layer
set. `schedule_csv::MaterialNames` holds the CSV's rule (profile set,
layer set, single material, constituents) and both use it.
- **Counts after `--revit-property-sets`.** `export_pipeline` called
`recount_exported` after every model-changing step but
`revit_property_sets::attach`, so `exported.total_entities` missed the
sets it adds.
- **No storey means the building.** `BuildingElement.storey_index`,
`ElementInput.storey_index`, a `step_writer` comment and the no-Level
warning said an element with no storey goes to storey 0, or to a
fallback storey. The writer contains it in the building (RE-27, RE-124),
and they now say so.
- **Docs that misstated the code.**
- `BuilderOptions.units` named a `build_unit_list` that does not exist,
and claimed the units become the `IfcUnitAssignment`; the writer's
assignment is fixed SI (#403).
  - `ScheduleRow.guid` is the ElementId, not the GlobalId.
- The pbr comment named the 2.2 gamma; the code applies the exact sRGB
curve.
- **Small guards.**
- The element panel prints a length that rounds to zero as `0.000`, as
its own rule says.
- The glTF export drops a material index past the model's materials, as
the STEP writer does.
- `attach_wall_top_joins` replaces `m_wall_top_joined` rather than
pushing a second copy.

## Motivation

Batch 9, an export bug hunt: 40 DeepSeek checkers and 30 verifiers,
$3.79. Two other fixes from it change exports and are their own PRs:
#1939 (the opening box height) and #1940 (material colours). The rules
that run on unmeasured releases are #1945.

## Testing

No IFC value changes. `diagnostics.json` changes only in the no-Level
warning's text, and in `total_entities` under `--revit-property-sets`,
which no Measure run uses. The unfiltered Measure with the samples is in
this PR's comments, to show the exports byte-identical and give the
gates verdict.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR
- [x] A user-visible change has its entry as a fragment under
`changelog.d/fixed/`
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