mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 12:34:00 +00:00
Minor fix for #1699
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||||
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
||||||
#
|
#
|
||||||
@@ -43,10 +42,8 @@ class EnableEditingGeoreferencing(bpy.types.Operator):
|
|||||||
props.projected_crs.clear()
|
props.projected_crs.clear()
|
||||||
|
|
||||||
blenderbim.bim.helper.import_attributes(
|
blenderbim.bim.helper.import_attributes(
|
||||||
"IfcProjectedCRS",
|
"IfcProjectedCRS", props.projected_crs, Data.projected_crs, self.import_projected_crs_attributes
|
||||||
props.projected_crs,
|
)
|
||||||
Data.projected_crs,
|
|
||||||
self.import_projected_crs_attributes)
|
|
||||||
|
|
||||||
props.map_conversion.clear()
|
props.map_conversion.clear()
|
||||||
blenderbim.bim.helper.import_attributes(
|
blenderbim.bim.helper.import_attributes(
|
||||||
@@ -68,11 +65,11 @@ class EnableEditingGeoreferencing(bpy.types.Operator):
|
|||||||
new.data_type = "enum"
|
new.data_type = "enum"
|
||||||
new.is_null = data[name] is None
|
new.is_null = data[name] is None
|
||||||
new.is_optional = True
|
new.is_optional = True
|
||||||
new.enum_items = json.dumps({
|
new.enum_items = json.dumps(
|
||||||
u["id"]: u["Name"]
|
{u["id"]: u["Name"] for u in UnitData.units.values() if u["UnitType"] == "LENGTHUNIT"}
|
||||||
for u in UnitData.units.values()
|
)
|
||||||
if u["UnitType"] == "LENGTHUNIT"
|
if data["MapUnit"]:
|
||||||
})
|
new.enum_value = str(data["MapUnit"]["id"])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def import_map_conversion_attributes(self, name, prop, data):
|
def import_map_conversion_attributes(self, name, prop, data):
|
||||||
@@ -285,8 +282,7 @@ class ConvertGlobalToLocal(bpy.types.Operator):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
file = IfcStore.get_file()
|
file = IfcStore.get_file()
|
||||||
props = context.scene.BIMGeoreferenceProperties
|
props = context.scene.BIMGeoreferenceProperties
|
||||||
return file and file.by_type("IfcUnitAssignment") \
|
return file and file.by_type("IfcUnitAssignment") and props.coordinate_input.count(",") == 2
|
||||||
and props.coordinate_input.count(",") == 2
|
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
if not Data.is_loaded:
|
if not Data.is_loaded:
|
||||||
|
|||||||
@@ -20,39 +20,8 @@ class Usecase:
|
|||||||
setattr(map_conversion, name, value)
|
setattr(map_conversion, name, value)
|
||||||
for name, value in self.settings["projected_crs"].items():
|
for name, value in self.settings["projected_crs"].items():
|
||||||
setattr(projected_crs, name, value)
|
setattr(projected_crs, name, value)
|
||||||
self.remove_existing_map_unit(projected_crs)
|
|
||||||
self.set_map_unit(projected_crs)
|
|
||||||
self.set_true_north()
|
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):
|
def set_true_north(self):
|
||||||
if self.settings["true_north"] == []:
|
if self.settings["true_north"] == []:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user