Skip to content

Python API

import bimora

Functions that take a model accept a file path (str / Path) or a ModelData returned by bimora.read_model(), so a file can be parsed once and reused. Keyword arguments max_bytes and allow_untested_schema are passed to the loader.

Function Returns
read_model(path, *, max_bytes=…, allow_untested_schema=False) ModelData (all extracted records)
load_model(path, …) LoadedModel (IfcOpenShell file + header + schema) for advanced use
sniff_schema(path) declared schema without parsing
inspect_model(source) dict summary: schema, project, units, counts, storeys, property / quantity sets, materials, classification systems
validate_model(source, config=None) ValidationResult (findings, counts, by_rule(), at_least(sev), to_dict())
extract_spaces(source) list[dict] room inventory
extract_properties(source, include_spaces=True) list[dict] one row per property value
export_model(source, format="json"\|"csv", output=None) JSON document (dict), or dict of written CSV paths
compare_models(before, after) ComparisonResult (added, removed, changed, summary, warnings, to_dict())
build_report(source, config=None, area_unit="m2", min_severity="info") report dict (no timestamps — reproducible)
convert(value, from_unit, to_unit) float

Errors derive from bimora.BimoraError: InputError, FileTooLargeError, UnsupportedFormatError, UnsupportedSchemaError, ParseError, ConfigError.

Examples

from bimora import read_model, validate_model, extract_spaces, build_report

model = read_model("examples/pavilion-ifc4.ifc")

for room in extract_spaces(model):
    area = room["NetFloorArea"]
    print(room["number"], room["name"], area and f'{area["value"]} {area["unit"]}')

result = validate_model(model, config="examples/validation-config.toml")
errors = result.at_least("error")
print(result.counts, len(errors))

report = build_report(model, area_unit="ft2")

Records (bimora.ifc.model): ModelData (spatial, spaces, elements, units, project, header, storeys, buildings), Element (global_id, ifc_class, name, storey_name, properties, quantities, materials, classifications, quantity(name)), SpatialNode, Quantity (value, unit, si_value, kind, source="declared").

Lower-level modules (bimora.spatial.analysis, bimora.interoperability.*, bimora.validation.*) are usable directly; they are documented in their docstrings. Until v1.0.0 their signatures may change between minor versions.