Naive implementation of file stream and Lark based IFC-SPF reader to handle huge IFCs.

This commit is contained in:
Dion Moult
2023-06-27 21:02:50 +10:00
parent 7e2b40176c
commit 183230b7f5
3 changed files with 382 additions and 12 deletions
@@ -72,6 +72,7 @@ from . import guid
from .file import file
from .entity_instance import entity_instance, register_schema_attributes
from .sql import sqlite, sqlite_entity
from .stream import stream, stream_entity
READ_ERROR = ifcopenshell_wrapper.file_open_status.READ_ERROR
NO_HEADER = ifcopenshell_wrapper.file_open_status.NO_HEADER
@@ -88,7 +89,7 @@ class SchemaError(Error):
pass
def open(path: "os.PathLike | str", format: str = None) -> file:
def open(path: "os.PathLike | str", format: str = None, should_stream: bool = False) -> file:
"""Loads an IFC dataset from a filepath
You can specify a file format. If no format is given, it is guessed from its extension.
@@ -117,6 +118,8 @@ def open(path: "os.PathLike | str", format: str = None) -> file:
raise LookupError(f"No .ifc or .ifcXML file found in {path}")
if format == ".ifcSQLite":
return sqlite(path)
if should_stream:
return stream(path)
f = ifcopenshell_wrapper.open(str(path.absolute()))
if f.good():
return file(f)