mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Naive implementation of file stream and Lark based IFC-SPF reader to handle huge IFCs.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user