From ba443232b36e813f8f61bde73a2ed3d151a91ff4 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 9 Oct 2019 10:01:41 +1100 Subject: [PATCH] Bug #663 - Implement support for COBie coordinates spreadsheet --- src/ifcblenderexport/cobie.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/ifcblenderexport/cobie.py b/src/ifcblenderexport/cobie.py index 505df95a54..32fc83dec0 100644 --- a/src/ifcblenderexport/cobie.py +++ b/src/ifcblenderexport/cobie.py @@ -23,6 +23,7 @@ class IfcCobieCsv(): self.impacts = {} self.documents = {} self.attributes = {} + self.coordinates = {} self.type_assets = [ 'IfcDoorStyle', 'IfcBuildingElementProxyType', @@ -112,6 +113,7 @@ class IfcCobieCsv(): self.get_impacts() self.get_documents() self.get_attributes() + self.get_coordinates() def get_contacts(self): histories = self.file.by_type('IfcOwnerHistory') @@ -494,6 +496,31 @@ class IfcCobieCsv(): 'AllowedValues': 'n/a', } + def get_coordinates(self): + coordinates = self.file.by_type('IfcBuildingStorey') \ + + self.file.by_type('IfcSpace') \ + + self.file.by_type('IfcProduct') + for coordinate in coordinates: + coordinate_name = '{}/{}'.format(coordinate.is_a(), self.get_object_name(coordinate)) + self.coordinates[coordinate_name] = { + 'CreatedBy': self.get_email_from_history(coordinate.OwnerHistory), + 'CreatedOn': self.get_created_on_from_history(coordinate.OwnerHistory), + 'Category': 'Location', # I am not sure what this mapping is meant to be + 'SheetName': 'Coordinates', + 'RowName': 'n/a', + 'CoordinateXAxis': coordinate.ObjectPlacement.RelativePlacement.Location.Coordinates[0], + 'CoordinateYAxis': coordinate.ObjectPlacement.RelativePlacement.Location.Coordinates[1], + 'CoordinateZAxis': coordinate.ObjectPlacement.RelativePlacement.Location.Coordinates[2], + 'ExtSystem': self.get_ext_system_from_history(coordinate.OwnerHistory), + 'ExtObject': self.get_ext_object(coordinate), + 'ExtIdentifier': coordinate.GlobalId, + # Holding off implementing this, see Bug #688: + # https://github.com/IfcOpenShell/IfcOpenShell/issues/688 + 'ClockwiseRotation': 'n/a', # X axis + 'ElevationalRotation': 'n/a', # Y axis + 'YawRotation': 'n/a', # Z axis + } + def get_directory_from_document(self, document): if self.file.schema == 'IFC2X3': if document.HasDocumentReferences: @@ -911,4 +938,5 @@ pprint.pprint(ifc_cobie_csv.jobs) pprint.pprint(ifc_cobie_csv.impacts) pprint.pprint(ifc_cobie_csv.documents) pprint.pprint(ifc_cobie_csv.attributes) +pprint.pprint(ifc_cobie_csv.coordinates) print('# Finished conversion in {}s'.format(time.time() - start))