Add support for case insensitive file units on import

This commit is contained in:
Dion Moult
2020-11-02 10:20:44 +11:00
parent 163075a821
commit 3bc4e756cb
2 changed files with 9 additions and 6 deletions
@@ -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):
+2 -2
View File
@@ -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", ""),