Skip to content

Commit

Permalink
allow not loading geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
Licini committed Mar 26, 2024
1 parent a671591 commit d3526d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/compas_ifc/entities/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions src/compas_ifc/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/compas_ifc/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit d3526d5

Please sign in to comment.