From 3bc4e756cbb54c71f612620127c15e51be0835b9 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 2 Nov 2020 10:20:44 +1100 Subject: [PATCH] Add support for case insensitive file units on import --- src/ifcblenderexport/blenderbim/bim/import_ifc.py | 11 +++++++---- src/ifcblenderexport/blenderbim/bim/prop.py | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/import_ifc.py b/src/ifcblenderexport/blenderbim/bim/import_ifc.py index e7a295ff98..4056ac18f3 100644 --- a/src/ifcblenderexport/blenderbim/bim/import_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/import_ifc.py @@ -1451,17 +1451,20 @@ class IfcImporter: bpy.context.scene.unit_settings.length_unit = f"{unit.Prefix}METERS" else: bpy.context.scene.unit_settings.system = "IMPERIAL" - if unit.Name == "inch": + name = unit.Name.lower() + if name == "inch": bpy.context.scene.unit_settings.length_unit = "INCHES" - elif unit.Name == "foot": + elif name == "foot": bpy.context.scene.unit_settings.length_unit = "FEET" elif unit.is_a("IfcNamedUnit") and unit.UnitType == "AREAUNIT": + name = unit.Name if unit.is_a("IfcSIUnit") else unit.Name.lower() bpy.context.scene.BIMProperties.area_unit = "{}{}".format( - unit.Prefix + "/" if hasattr(unit, "Prefix") and unit.Prefix else "", unit.Name + unit.Prefix + "/" if hasattr(unit, "Prefix") and unit.Prefix else "", name ) elif unit.is_a("IfcNamedUnit") and unit.UnitType == "VOLUMEUNIT": + name = unit.Name if unit.is_a("IfcSIUnit") else unit.Name.lower() bpy.context.scene.BIMProperties.volume_unit = "{}{}".format( - unit.Prefix + "/" if hasattr(unit, "Prefix") and unit.Prefix else "", unit.Name + unit.Prefix + "/" if hasattr(unit, "Prefix") and unit.Prefix else "", name ) def create_geometric_representation_contexts(self): diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 4a2254e79a..3dca1ae46b 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -1468,7 +1468,7 @@ class BIMProperties(PropertyGroup): area_unit: EnumProperty( items=[ ("square centimeters", "square centimeters", ""), - ("square feet", "square feet", ""), + ("square foot", "square foot", ""), ("square inches", "square inches", ""), ("square kilometers", "square kilometers", ""), ("square meters", "square meters", ""), @@ -1481,7 +1481,7 @@ class BIMProperties(PropertyGroup): volume_unit: EnumProperty( items=[ ("cubic centimeters", "cubic centimeters", ""), - ("cubic feet", "cubic feet", ""), + ("cubic foot", "cubic foot", ""), ("cubic inches", "cubic inches", ""), ("cubic meters", "cubic meters", ""), ("cubic millimeters", "cubic millimeters", ""),