From d3526d58b8f24865ac3e054c0232ac7ce45e5f01 Mon Sep 17 00:00:00 2001 From: Licini Date: Tue, 26 Mar 2024 17:28:58 +0100 Subject: [PATCH] allow not loading geometries --- src/compas_ifc/entities/entity.py | 6 ++++++ src/compas_ifc/model.py | 8 ++++---- src/compas_ifc/reader.py | 5 +++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/compas_ifc/entities/entity.py b/src/compas_ifc/entities/entity.py index a753ed1d..b1dfe5ce 100644 --- a/src/compas_ifc/entities/entity.py +++ b/src/compas_ifc/entities/entity.py @@ -52,6 +52,12 @@ def declaration(self): self._declaration = self.model.schema.declaration_by_name(self.ifc_type) return self._declaration + @property + def id(self): + if self._entity: + return self._entity.id() + return None + @property def ifc_type(self): if self._entity: diff --git a/src/compas_ifc/model.py b/src/compas_ifc/model.py index f0cabd32..d531ef5a 100644 --- a/src/compas_ifc/model.py +++ b/src/compas_ifc/model.py @@ -59,7 +59,7 @@ class Model: """ - def __init__(self, filepath: str = None, entity_types: dict = None, use_occ=False, schema=None) -> None: + def __init__(self, filepath: str = None, entity_types: dict = None, use_occ=False, schema=None, load_geometries=True) -> None: self.reader = IFCReader(model=self, entity_types=entity_types, use_occ=use_occ) self.writer = IFCWriter(model=self) self._new_entities = set() @@ -75,10 +75,10 @@ def __init__(self, filepath: str = None, entity_types: dict = None, use_occ=Fals self._schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema) if filepath: - self.open(filepath) + self.open(filepath, load_geometries=load_geometries) - def open(self, filepath: str) -> None: - self.reader.open(filepath) + def open(self, filepath: str, load_geometries=True) -> None: + self.reader.open(filepath, load_geometries=load_geometries) def save(self, filepath: str) -> None: self.writer.save(filepath) diff --git a/src/compas_ifc/reader.py b/src/compas_ifc/reader.py index 3e7d928d..b7a05448 100644 --- a/src/compas_ifc/reader.py +++ b/src/compas_ifc/reader.py @@ -60,13 +60,14 @@ def __init__(self, model, entity_types: dict = None, use_occ=True): self._geometrymap = {} self._stylemap = {} - def open(self, filepath: str): + def open(self, filepath: str, load_geometries=True): self.filepath = filepath self._file = ifcopenshell.open(filepath) self._schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(self._file.schema) self._entitymap = {} print("Opened file: {}".format(filepath)) - self.load_geometries() + if load_geometries: + self.load_geometries() def get_entity(self, entity: ifcopenshell.entity_instance): """