krzysztofarendt / building3d

Towards 3D building modeling and simulation
MIT License
20 stars 2 forks source link

Read .bim files generated by other software #99

Open krzysztofarendt opened 3 weeks ago

krzysztofarendt commented 3 weeks ago

Currently I can export to .bim and read from .bim exported by building3d. However, I cannot import models exported from other software, because I need specific metadata in the .bim file.

So I have this check when reading a .bim file:

def read_dotbim(path: str) -> Building:
    """Load model from .bim."""
    bim = {}
    with open(path, "r") as f:
        bim = json.load(f)

    error_msg = ".bim format not compatible with Building3D"
    if not "generated_by" in bim["info"].keys():
        raise KeyError(error_msg)
    elif bim["info"]["generated_by"] != TOOL_NAME:
        raise ValueError(error_msg)

Proposed fix: