From 5ad7d4bb2a43d3a3f4d4f0172999263aca3bba09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Dukai?= Date: Sat, 10 Jun 2023 07:00:32 +0200 Subject: [PATCH] Update to ifcopenshell 0.7.0 and cjio 0.8 LoD is string in v1.1 --- src/ifccityjson/README.md | 2 +- src/ifccityjson/cityjson2ifc/cityjson2ifc.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ifccityjson/README.md b/src/ifccityjson/README.md index 4d2d537345..5bca24f4bd 100644 --- a/src/ifccityjson/README.md +++ b/src/ifccityjson/README.md @@ -3,7 +3,7 @@ Converter for CityJSON files and IFC. Currently only supports one-way conversion ## Dependencies - [IfcOpenShell](https://github.com/IfcOpenShell/IfcOpenShell) (also IfcOpenShell api is needed) -- [CJIO](https://github.com/cityjson/cjio) +- [CJIO](https://github.com/cityjson/cjio) (>=0.8, <1.0) ## Usage of IFCCityJSON An extended ifccityjson tutorial can be found on [the OSARCH wiki](https://wiki.osarch.org/index.php?title=Ifccityjson) diff --git a/src/ifccityjson/cityjson2ifc/cityjson2ifc.py b/src/ifccityjson/cityjson2ifc/cityjson2ifc.py index 81b2e10fc8..79e0d8aaf6 100644 --- a/src/ifccityjson/cityjson2ifc/cityjson2ifc.py +++ b/src/ifccityjson/cityjson2ifc/cityjson2ifc.py @@ -45,7 +45,7 @@ JSON_TO_IFC = { "SolitaryVegetationObject": ["IfcGeographicElement", {"PredefinedType": "USERDEFINED", "ObjectType": "SolitaryVegetationObject"}], "CityFurniture": ["IfcFurnishingElement"], - "GenericCityObject": ["IfcCivilElement"], + "OtherConstruction": ["IfcCivilElement"], "Bridge": ["IfcCivilElement"], # Update for IFC4.3 "BridgePart": ["IfcCivilElement"], # Update for IFC4.3 "BridgeInstallation": ["IfcCivilElement"], # Update for IFC4.3 @@ -118,9 +118,9 @@ class Cityjson2ifc: # Georeferencing self.properties["local_translation"] = None self.properties["local_scale"] = None - if self.city_model.is_transform(): - self.properties["local_scale"] = self.city_model.j['transform']['scale'] - local_translation = self.city_model.j['transform']['translate'] + if not self.city_model.is_transformed: + self.properties["local_scale"] = self.city_model.transform['scale'] + local_translation = self.city_model.transform['translate'] self.properties["local_translation"] = { "Eastings": local_translation[0], "Northings": local_translation[1], @@ -141,7 +141,7 @@ class Cityjson2ifc: ifcopenshell.api.run("unit.assign_unit", self.IFC_model, length={"is_metric": True, "raw": "METERS"}) self.properties["owner_history"] = self.create_owner_history() self.IFC_representation_context = ifcopenshell.api.run("context.add_context", self.IFC_model, - **{"context": "Model"}) + **{"context_type": "Model"}) if not self.city_model.has_metadata() or "presentLoDs" not in self.city_model.j["metadata"]: self.city_model.update_metadata() @@ -174,7 +174,7 @@ class Cityjson2ifc: "ContextIdentifier": "Body", "TargetView": "USERDEFINED", "ParentContext": self.IFC_representation_context, - "UserDefinedTargetView": "LOD" + str(lod)}) + "UserDefinedTargetView": "LOD" + lod}) def create_owner_history(self): actor = self.IFC_model.createIfcActorRole("ENGINEER", None, None) @@ -246,10 +246,10 @@ class Cityjson2ifc: IFC_shape_representations = [] for geometry in obj.geometry: lod = geometry.lod - if self.properties["lod"] is not None and str(lod) != self.properties["lod"]: + if self.properties["lod"] is not None and lod != self.properties["lod"]: continue - if str(lod) not in self.IFC_representation_sub_contexts: - self.IFC_representation_sub_contexts[str(lod)] = self.create_representation_sub_context(lod) + if lod not in self.IFC_representation_sub_contexts: + self.IFC_representation_sub_contexts[lod] = self.create_representation_sub_context(lod) IFC_geometry, shape_representation_type = None, None @@ -325,7 +325,7 @@ class Cityjson2ifc: IFC_geometry = [IFC_geometry] shape_representation = self.IFC_model.create_entity("IfcShapeRepresentation", - self.IFC_representation_sub_contexts[str(lod)], 'Body', + self.IFC_representation_sub_contexts[lod], 'Body', shape_representation_type, IFC_geometry) return shape_representation