Skip to content

Commit

Permalink
fix print_summary with empty model
Browse files Browse the repository at this point in the history
  • Loading branch information
Licini committed Aug 20, 2024
1 parent bd3a555 commit a237df4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/compas_ifc/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def entities(self) -> Generator["Base", None, None]:

@property
def project(self) -> "IfcProject":
return self.file.get_entities_by_type("IfcProject")[0]
projects = self.file.get_entities_by_type("IfcProject")
return projects[0] if projects else None

@property
def sites(self) -> list["IfcSite"]:
Expand Down Expand Up @@ -99,10 +100,13 @@ def print_summary(self):
Plot of spatial hierarchy"""

print("=" * 80)
print("File: {}".format(self.file.filepath))
print("Size: {} MB".format(self.file.file_size()))
print("Project: {}".format(self.project.Name))
print("Description: {}".format(self.project.Description))
print("Schema: {}".format(self.schema_name))
if self.file.filepath:
print("File: {}".format(self.file.filepath))
print("Size: {} MB".format(self.file.file_size()))
if self.project:
print("Project: {}".format(self.project.Name))
print("Description: {}".format(self.project.Description))
print("Number of sites: {}".format(len(self.sites)))
print("Number of buildings: {}".format(len(self.buildings)))
print("Number of building elements: {}".format(len(self.building_elements)))
Expand Down

0 comments on commit a237df4

Please sign in to comment.