From b5d43b1d586986fcb92ff598cad55ce6bd2ffdd7 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 25 Oct 2020 13:12:14 +1100 Subject: [PATCH] Fix #1036. Fix export issue where units aren't set explicitly, or set to adaptive. --- .../blenderbim/bim/export_ifc.py | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/bim/export_ifc.py b/src/ifcblenderexport/blenderbim/bim/export_ifc.py index 9bd2a1118e..07c266842c 100644 --- a/src/ifcblenderexport/blenderbim/bim/export_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/export_ifc.py @@ -126,25 +126,31 @@ class IfcParser(): self.spatial_structure_elements_tree.extend(self.get_spatial_structure_elements_tree(project)) def get_units(self): - return { + units = { 'length': { 'ifc': None, - 'is_metric': bpy.context.scene.unit_settings.system == 'METRIC', + 'is_metric': bpy.context.scene.unit_settings.system != 'IMPERIAL', 'raw': bpy.context.scene.unit_settings.length_unit }, 'area': { 'ifc': None, - 'is_metric': bpy.context.scene.unit_settings.system == 'METRIC', + 'is_metric': bpy.context.scene.unit_settings.system != 'IMPERIAL', 'raw': bpy.context.scene.unit_settings.length_unit }, 'volume': { 'ifc': None, - 'is_metric': bpy.context.scene.unit_settings.system == 'METRIC', + 'is_metric': bpy.context.scene.unit_settings.system != 'IMPERIAL', 'raw': bpy.context.scene.unit_settings.length_unit }} + for data in units.values(): + if data['raw'] == 'ADAPTIVE': + if data['is_metric']: + data['raw'] = 'METERS' + else: + data['raw'] = 'FEET' + return units def get_unit_scale(self): - unit_settings = bpy.context.scene.unit_settings conversions = { 'KILOMETERS': 1e3, 'CENTIMETERS': 1e-2, @@ -152,12 +158,13 @@ class IfcParser(): 'MICROMETERS': 1e-6, 'FEET': 0.3048, 'INCHES': 0.0254} - if unit_settings.system in {'METRIC', 'IMPERIAL'}: - scale = unit_settings.scale_length - if unit_settings.length_unit in conversions.keys(): - scale *= conversions[unit_settings.length_unit] - return scale - return 1 + if bpy.context.scene.unit_settings.system in {'METRIC', 'IMPERIAL'}: + scale = bpy.context.scene.unit_settings.scale_length + else: + scale = 1 + if self.units['length']['raw'] in conversions.keys(): + scale *= conversions[self.units['length']['raw']] + return scale def get_object_attributes(self, obj): attributes = {'Name': self.get_ifc_name(obj.name)}