Skip to content

Element materials: shading colours decode exactly; names and the element-to-material link do not yet #355

Closed

Description

@DrunkOnJava

Elements export and display without their Revit material. The viewer colours them by category (#350). This issue records what is measured so far on the way to real materials, and what is still missing.

Measured

Material objects:

  • A material is serialised as 01 00 00 00 · u64 id, the same object shape as a run type (RE-52), with a class tag 0x47 bytes past the id.
  • The tag is 0x0a28 on Revit 2024 and 0x0a6b on Revit 2025. Found this way, the objects number exactly the OST_Materials records on every file measured: Snowdon Towers 220, Core Interior 86, RE1 Architecture 69, Projeto1 and teste_export_2025 114 each.
  • Some objects open with the element-data header; others sit inside another element's data.

Shading colour and transparency:

  • After the material's name, the first frame of this form holds the colour:
    • ff × 8;
    • an f32 transparency (0..1);
    • an f32 of 0.5 on every material seen;
    • four u32 COLORREFs (pattern colours);
    • the shading colour as a COLORREF (r g b 00);
    • a u32 shininess (64 by default).
  • Where a material's name reads, colour and transparency equal Revit's own IFC surface style of the same name on 43 of 43 materials, across the five files. The oracle is IfcSurfaceStyle name → IfcSurfaceStyleRendering → IfcColourRgb and Transparency.

Missing

  • Names. The first framed string after the id is the name on project materials: "Glass", "Soil" and the like, read as for system types (Names for system-family types (walls, floors, roofs) from schema-serialised partition data #322). On most materials loaded with families it is not: on 120 of Snowdon's objects it reads assetlibrary_base.fbx, an appearance asset reference. Only 28 of the 137 materials Revit's IFC writes for Snowdon are named this way. Some carry the name as a parameter entry i64 -1001203 · u32 0 · u32 n · UTF-16, 13 of Snowdon's objects.
  • The element-to-material link. This is the blocker. A wall type's record slots hold no material id, and neither does its serialised data, read as u64 or u32 (Core Interior type 17328, 0x865 bytes). The compound structure must be another object keyed by the type. Family instances take materials from type parameters, not yet traced.

Oracles

Revit's IFC4 exports:

  • local only: Snowdon Towers, Projeto1, teste_export_2025;
  • CI: RE1 (MIT) and Core Interior slim.

Revit's IFC styles geometry with the material's surface style, so an element's shaded colour can be measured end to end once the link is decoded.

Clean-room: byte observations only.

Activity

  1. DrunkOnJava commented on Sep 23, 2026

    @DrunkOnJava
    OwnerAuthor

    Progress on the element-to-material link, measured on the same five files.

    Host types' layers: decoded

    The compound structure of wall, floor, roof and ceiling types is in the type's own serialised data:

    • a u32 layer count, then one 37-byte record per layer, exterior first:
      • f64 width, ft;
      • u64 material id (ff×8 = by category);
      • u64 deck profile id (ff×8 = none);
      • u32 function (1 structure, 2 substrate, 3 thermal/air, 4 finish 1, 5 finish 2, 100 membrane);
      • then an index and a flag.
    • The count is framed one of two ways:
      • ff ff ff ff and a per-release tag, 0x10a6 on 2024 and 0x110e on 2025. On 2024 this follows the type's name string directly.
      • u32 k, k × 2d 00, u32 0 (2025 floors and ceilings).
    • Checked against Revit's own material sets:
      • Snowdon Towers: 42 of 42 types give Revit's constituent sequence exactly, once the 0 mm membranes Revit leaves out are dropped.
      • Core Interior: 4 of 4. Its layers are "by category", which Revit writes as Default Wall.
      • RE1 Architecture: the wall, both floors and the ceiling give Revit's layer thicknesses and materials (15/100/15 mm gypsum, stud, gypsum; 10/10 mm; 20/20 mm; 100/15 mm).
    • Earlier "no material ids in type 17328" was because Core's layers are by category.

    Colours: from the id, no name needed

    The colour frame is found as the first one after the material's id. It equals Revit's surface style on 123 of 123 materials whose name is known. The 8 apparent misses were all a wrong name candidate, not a wrong colour.

    Still blocking

    • Names. Neither rule is clean.
      • The first framed string after the id is right on project materials. On family materials it reads an appearance asset (assetlibrary_base.fbx).
      • The i64 -1001203 entry (u32 0, optionally another u32 0, u32 n, UTF-16) names many family materials. It also holds binary strings on others. The best bounded rule names 92 of the 174 materials Revit exports, with too many garbage picks to ship.
      • IFC materials need names, so layer sets wait on this.
    • Layer order for display. Revit's IFC splits a layered wall's body into one solid per layer, each styled with its layer's material. On Snowdon, 998 of the 1,020 hosts with a constituent set style every one of their layers. Drawing that needs the wall's exterior side (location line and flip), which is not decoded. A single colour per wall would be a guess.

    Next steps:

    • find the material name field;
    • read the wall's orientation, then draw layers with their colours.
  2. DrunkOnJava commented on Sep 23, 2026

    @DrunkOnJava
    OwnerAuthor

    Wall exterior side, measured and not yet found.

    • 1,096 of Snowdon's 1,120 walls carry their location line as a bounded line record (RE-49's 04 00 08 01) in their data, so each wall's direction is known.
    • Against the VIM's per-submesh materials, 336 walls whose first and last layers differ in colour put their first (exterior) layer on the right of the line direction on 182 and on the left on 154. On 11 of the 17 wall types, instances are mixed, so the side is set per instance: the wall's flip.
    • No single bit predicts the side at a fixed offset (above 90%) in the wall's element data (−0x300..+0x600 around the header and around the line record), nor above 80% in the first 0x200 bytes of its partition record.
    • The VIM is the 2027 edition, so part of the disagreement may be edition drift. Next time, measure the side against Revit's 2024 IFC per-layer body solids, meshed by IfcOpenShell. Then look for the flip as a field, not a fixed offset.
  3. DrunkOnJava commented on Sep 24, 2026

    @DrunkOnJava
    OwnerAuthor

    The element-to-material link is found for host elements. It is not in the type's record but in the type's own element data (RE-53).

    • Layers. A wall, floor, roof or ceiling type's data holds a u32 layer count, then one 37-byte record per layer, exterior or top first:

      • f64 width;
      • u64 material ElementId, or ff × 8 for by category;
      • u64 deck profile;
      • u32 function.

      The count is framed by ff ff ff ff and a per-release tag (a6 10 on 2024, 0e 11 on 2025), or by u32 k · k × 2d 00 · u32 0 on 2025 floors and ceilings. Snowdon gives Revit's constituent sequence on 42 of 42 types, Core Interior on 4 of 4, and RE1 on its wall, floors and ceiling.

    • Which side is the exterior. A wall's data carries its location line, a word and a flip flag after ff ff ff ff 01 00 00 00. With the flag set, the first layer lies right of the location line's direction. This holds on all 416 Snowdon walls where it can be measured.

    • Drawn. The glTF export and viewer now draw 2024 walls as their layers in their materials' shading colours. Scored end to end against Revit's IFC4 per-layer solids on Snowdon:

      • every layer centre is within 0.001 ft on 851 of 862 walls;
      • all 1,368 compared layer colours equal Revit's surface style colours.

      The colour check needs no names: the layer names its material by id, and Revit styles that layer's faces.

    Still missing:

    • Names. So the IFC export writes no IfcMaterialLayerSet or surface style yet.
    • Family instances' materials. They come through type parameters, not yet traced.
    • Floor, roof and ceiling layers. They are read but not drawn.
    • Revit 2025 walls. Their location lines are not read.

    Report: reports/element-framing/RE-53-wall-layers.md. PR to follow.

  4. DrunkOnJava commented on Sep 24, 2026

    @DrunkOnJava
    OwnerAuthor

    Landed in #359: material shading colours, host type layers and wall sides. The glTF export and viewer draw Revit 2024 walls in their layers' colours. Names and the IFC layer sets remain open here.

  5. DrunkOnJava commented on Sep 24, 2026

    @DrunkOnJava
    OwnerAuthor

    Material names: measured, not yet shipped.

    Ground truth came from walls and slabs: a type's layers name their materials by ElementId (RE-53), and Revit's IFC names the same layers' materials in the same order. On Snowdon Towers this gives 42 id-to-name pairs. Two of those pairs turned out to be swapped in Revit's layer order.

    Where a material's own name sits in its object, on Revit 2024:

    • Its own name field. Right after the class tag (28 0a at +0x47), 8 zero bytes, then u32 n and UTF-16 at +0x51 (for example "Mirror", "Matte Black"). A slot there that holds u32 1 followed by a BuiltInParameter id is not a name.
    • Otherwise, a parameter entry. BuiltInParameter −1001203 (0d b9 f0 ff ff ff ff ff), u32 0, u32 n, UTF-16.
    • Otherwise, a framed string. ff ff ff ff 49 01, u32 n, UTF-16.
    • A material object can also name another material further in. Taking the first of these strings instead gave duplicate names and wrong colours.

    With that order, on Snowdon:

    • 111 of the 137 material names in Revit's IFC are produced;
    • every produced name's decoded shading colour equals the colour of Revit's surface style of that name, 111 of 112 (the one miss is a duplicate);
    • Core Interior (2024): 8 of 10 names, with 7 of 8 colours equal.

    Revit 2025 differs:

    • the framed string's tag is 5c 01, not 49 01;
    • BuiltInParameter −1010103 (49 96 f0 ff…) carries the name on RE1 ("Gypsum Wall Board"), where on Snowdon (2024) it carries a description ("Steel, mill finish");
    • RE1 gives 8 of 20 names this way and teste_export_2025 none.

    A per-release model of the material object is needed before names ship. The IFC layer sets (#88) follow once they do.

  6. DrunkOnJava commented on Sep 24, 2026

    @DrunkOnJava
    OwnerAuthor

    RE-58 reads material names by ElementId, including the 2025 layout this issue left open.

    A material's own name field can hold parameter entries before its name:

    • strings: i64 BuiltInParameter · u32 n · UTF-16 × n;
    • integers: i64 BuiltInParameter · u32 value.

    The name comes after them. On every such material measured, it ends with ff ff ff ff and a release tag: 17 0c on 2024 and 6b 0c on 2025. RE1's floor finishes are an example: 8 entries come first, and the name sits at +0xf8.

    partition_materials::name_at reads, in order:

    • the name field directly;
    • the name ending at that terminator;
    • the framed string;
    • the -1001203 entry.

    Named:

    file release materials named
    Snowdon Towers 2024 219 of 220
    2024_Core_Interior 2024 78 of 86
    RE1 Architecture 2025 69 of 69
    the MIT tutorial house 2024 and 2025 171 of 171 in each
    Projeto1, teste_export_2025 2025 114 of 114 each

    Every named material that Revit's own export styles by that name has Revit's colour for it, 174 of 174.

    The IFC export now writes layer sets with these names. The layer names are Revit's, in Revit's order, on 3,321 of Snowdon's 3,322 layers and on all of Core Interior's and RE1's. Report: reports/element-framing/RE-58-material-layer-sets.md.

    Still open here:

    • the element-to-material link for family instances;
    • Snowdon 1924356, whose field holds a texture path and entries with no terminator in the window;
    • eight of Core Interior's family materials.

    The IFC's material list is still the string heuristic's; replacing it with these named records is #34.

    PR: #366.

  7. 45 remaining items

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:P1type:feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions