IFClite TypeScript API
    Preparing search index...

    Interface ApplyStyleOptions

    interface ApplyStyleOptions {
        followMappedItems?: boolean;
        replaceExisting?: boolean;
        schema?: "IFC2X3" | "IFC4" | "IFC4X3" | "IFC5";
    }
    Index
    followMappedItems?: boolean

    Style the geometry a type's occurrences share, rather than each occurrence (default true).

    Following IfcMappedItem to the IfcRepresentationMap is what makes one style cover every occurrence of a type, which is what you want colouring by IFC class. It is wrong for any other grouping: colouring by system, storey or property value, the shared geometry takes the colour of whichever batch touched it last, and occurrences in other groups change with it. Pass false to style the IfcMappedItem itself, one per occurrence.

    Do not mix the two settings over one model. They style different entities — the mapped item and the geometry behind it — so replaceExisting cannot see the conflict, and an occurrence ends up carrying both a shared style and its own, with the winner left to the viewer.

    replaceExisting?: boolean

    Replace a style the geometry already carries (default true). IFC allows at most one IfcStyledItem per representation item, so adding a second where one exists writes a schema-invalid file; the existing one is tombstoned instead. Pass false to leave already-styled geometry alone.

    schema?: "IFC2X3" | "IFC4" | "IFC4X3" | "IFC5"

    Schema the style chain is built for. Defaults to the store's own.

    IfcStyledItem.Styles holds IfcPresentationStyleAssignment on IFC2X3 and the IfcSurfaceStyle directly from IFC4 on, and this is decided when the style is authored, not when the file is written. Exporting to a different schema than the model was parsed from therefore needs the target passed in; otherwise the emitted records are invalid for the file they land in.

    Typed as the store's own schema union rather than a bare string: the two are halves of one decision, and a near-miss like 'IFC2x3' would otherwise typecheck and silently emit the IFC4 shape. IFC2X3 is the only member that differs; IFC4, IFC4X3 and IFC5 all take the IfcSurfaceStyle directly, which is why the branch tests for IFC2X3 rather than listing the rest.