Minor fix for #1699

This commit is contained in:
Dion Moult
2021-08-27 18:21:11 +10:00
parent 8d5970f002
commit 75a8e4af02
2 changed files with 9 additions and 44 deletions
@@ -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