From 75a8e4af026e5dc20766763754bfc2700df64618 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 27 Aug 2021 18:21:11 +1000 Subject: [PATCH] Minor fix for #1699 --- .../bim/module/georeference/operator.py | 22 ++++++------- .../api/georeference/edit_georeferencing.py | 31 ------------------- 2 files changed, 9 insertions(+), 44 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/georeference/operator.py b/src/blenderbim/blenderbim/bim/module/georeference/operator.py index 9c2f64f0eb..5b3e09037d 100644 --- a/src/blenderbim/blenderbim/bim/module/georeference/operator.py +++ b/src/blenderbim/blenderbim/bim/module/georeference/operator.py @@ -1,4 +1,3 @@ - # BlenderBIM Add-on - OpenBIM Blender Add-on # Copyright (C) 2020, 2021 Dion Moult # @@ -43,10 +42,8 @@ class EnableEditingGeoreferencing(bpy.types.Operator): props.projected_crs.clear() blenderbim.bim.helper.import_attributes( - "IfcProjectedCRS", - props.projected_crs, - Data.projected_crs, - self.import_projected_crs_attributes) + "IfcProjectedCRS", props.projected_crs, Data.projected_crs, self.import_projected_crs_attributes + ) props.map_conversion.clear() blenderbim.bim.helper.import_attributes( @@ -68,15 +65,15 @@ class EnableEditingGeoreferencing(bpy.types.Operator): new.data_type = "enum" new.is_null = data[name] is None new.is_optional = True - new.enum_items = json.dumps({ - u["id"]: u["Name"] - for u in UnitData.units.values() - if u["UnitType"] == "LENGTHUNIT" - }) + new.enum_items = json.dumps( + {u["id"]: u["Name"] for u in UnitData.units.values() if u["UnitType"] == "LENGTHUNIT"} + ) + if data["MapUnit"]: + new.enum_value = str(data["MapUnit"]["id"]) return True def import_map_conversion_attributes(self, name, prop, data): - if name not in ["SourceCRS", "TargetCRS"]: + if name not in ["SourceCRS", "TargetCRS"]: # Enforce a string data type to prevent data loss in single-precision Blender props prop.data_type = "string" prop.string_value = "" if prop.is_null else str(data[name]) @@ -285,8 +282,7 @@ class ConvertGlobalToLocal(bpy.types.Operator): def poll(cls, context): file = IfcStore.get_file() props = context.scene.BIMGeoreferenceProperties - return file and file.by_type("IfcUnitAssignment") \ - and props.coordinate_input.count(",") == 2 + return file and file.by_type("IfcUnitAssignment") and props.coordinate_input.count(",") == 2 def execute(self, context): if not Data.is_loaded: diff --git a/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_georeferencing.py b/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_georeferencing.py index e4ac84221a..f1806b4496 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_georeferencing.py +++ b/src/ifcopenshell-python/ifcopenshell/api/georeference/edit_georeferencing.py @@ -20,39 +20,8 @@ class Usecase: setattr(map_conversion, name, value) for name, value in self.settings["projected_crs"].items(): setattr(projected_crs, name, value) - self.remove_existing_map_unit(projected_crs) - self.set_map_unit(projected_crs) self.set_true_north() - def remove_existing_map_unit(self, projected_crs): - if projected_crs.MapUnit and len(self.file.get_inverse(projected_crs.MapUnit)) == 1: - # TODO: go deeper for conversion units - self.file.remove(projected_crs.MapUnit) - - def set_map_unit(self, projected_crs): - if not self.settings["map_unit"]: - return - - if "METRE" in self.settings["map_unit"]: - projected_crs.MapUnit = self.file.createIfcSIUnit( - None, - "LENGTHUNIT", - ifcopenshell.util.unit.get_prefix(self.settings["map_unit"]), - ifcopenshell.util.unit.get_unit_name(self.settings["map_unit"]), - ) - return - - value_component = self.file.create_entity( - "IfcReal", **{"wrappedValue": ifcopenshell.util.unit.si_conversions[self.settings["map_unit"]]} - ) - si_unit = self.file.createIfcSIUnit(None, "LENGTHUNIT", None, "METRE") - projected_crs.MapUnit = self.file.createIfcConversionBasedUnit( - self.file.createIfcDimensionalExponents(1, 0, 0, 0, 0, 0, 0), - "LENGTHUNIT", - self.settings["map_unit"], - self.file.createIfcMeasureWithUnit(value_component, si_unit), - ) - def set_true_north(self): if self.settings["true_north"] == []: return