mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
Fix #1036. Fix export issue where units aren't set explicitly, or set to adaptive.
This commit is contained in:
@@ -126,25 +126,31 @@ class IfcParser():
|
|||||||
self.spatial_structure_elements_tree.extend(self.get_spatial_structure_elements_tree(project))
|
self.spatial_structure_elements_tree.extend(self.get_spatial_structure_elements_tree(project))
|
||||||
|
|
||||||
def get_units(self):
|
def get_units(self):
|
||||||
return {
|
units = {
|
||||||
'length': {
|
'length': {
|
||||||
'ifc': None,
|
'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
|
'raw': bpy.context.scene.unit_settings.length_unit
|
||||||
},
|
},
|
||||||
'area': {
|
'area': {
|
||||||
'ifc': None,
|
'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
|
'raw': bpy.context.scene.unit_settings.length_unit
|
||||||
},
|
},
|
||||||
'volume': {
|
'volume': {
|
||||||
'ifc': None,
|
'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
|
'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):
|
def get_unit_scale(self):
|
||||||
unit_settings = bpy.context.scene.unit_settings
|
|
||||||
conversions = {
|
conversions = {
|
||||||
'KILOMETERS': 1e3,
|
'KILOMETERS': 1e3,
|
||||||
'CENTIMETERS': 1e-2,
|
'CENTIMETERS': 1e-2,
|
||||||
@@ -152,12 +158,13 @@ class IfcParser():
|
|||||||
'MICROMETERS': 1e-6,
|
'MICROMETERS': 1e-6,
|
||||||
'FEET': 0.3048,
|
'FEET': 0.3048,
|
||||||
'INCHES': 0.0254}
|
'INCHES': 0.0254}
|
||||||
if unit_settings.system in {'METRIC', 'IMPERIAL'}:
|
if bpy.context.scene.unit_settings.system in {'METRIC', 'IMPERIAL'}:
|
||||||
scale = unit_settings.scale_length
|
scale = bpy.context.scene.unit_settings.scale_length
|
||||||
if unit_settings.length_unit in conversions.keys():
|
else:
|
||||||
scale *= conversions[unit_settings.length_unit]
|
scale = 1
|
||||||
return scale
|
if self.units['length']['raw'] in conversions.keys():
|
||||||
return 1
|
scale *= conversions[self.units['length']['raw']]
|
||||||
|
return scale
|
||||||
|
|
||||||
def get_object_attributes(self, obj):
|
def get_object_attributes(self, obj):
|
||||||
attributes = {'Name': self.get_ifc_name(obj.name)}
|
attributes = {'Name': self.get_ifc_name(obj.name)}
|
||||||
|
|||||||
Reference in New Issue
Block a user