Fix #1036. Fix export issue where units aren't set explicitly, or set to adaptive.

This commit is contained in:
Dion Moult
2020-10-25 13:12:14 +11:00
parent 4ebed8d029
commit b5d43b1d58
@@ -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]
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
return 1
def get_object_attributes(self, obj):
attributes = {'Name': self.get_ifc_name(obj.name)}