mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
IFC unit settings are now preserved on import
This commit is contained in:
@@ -227,6 +227,7 @@ class IfcImporter():
|
|||||||
if self.ifc_import_settings.should_auto_set_workarounds:
|
if self.ifc_import_settings.should_auto_set_workarounds:
|
||||||
self.auto_set_workarounds()
|
self.auto_set_workarounds()
|
||||||
self.calculate_unit_scale()
|
self.calculate_unit_scale()
|
||||||
|
self.set_units()
|
||||||
self.create_geometric_representation_contexts()
|
self.create_geometric_representation_contexts()
|
||||||
self.create_project()
|
self.create_project()
|
||||||
self.create_classifications()
|
self.create_classifications()
|
||||||
@@ -706,7 +707,7 @@ class IfcImporter():
|
|||||||
units = self.file.by_type('IfcUnitAssignment')[0]
|
units = self.file.by_type('IfcUnitAssignment')[0]
|
||||||
for unit in units.Units:
|
for unit in units.Units:
|
||||||
if not hasattr(unit, 'UnitType') \
|
if not hasattr(unit, 'UnitType') \
|
||||||
or unit.UnitType != 'LENGTHUNIT':
|
or unit.UnitType != 'LENGTHUNIT':
|
||||||
continue
|
continue
|
||||||
while unit.is_a('IfcConversionBasedUnit'):
|
while unit.is_a('IfcConversionBasedUnit'):
|
||||||
self.unit_scale *= unit.ConversionFactor.ValueComponent.wrappedValue
|
self.unit_scale *= unit.ConversionFactor.ValueComponent.wrappedValue
|
||||||
@@ -714,6 +715,24 @@ class IfcImporter():
|
|||||||
if unit.is_a('IfcSIUnit'):
|
if unit.is_a('IfcSIUnit'):
|
||||||
self.unit_scale *= SIUnitHelper.get_prefix_multiplier(unit.Prefix)
|
self.unit_scale *= SIUnitHelper.get_prefix_multiplier(unit.Prefix)
|
||||||
|
|
||||||
|
def set_units(self):
|
||||||
|
units = self.file.by_type('IfcUnitAssignment')[0]
|
||||||
|
for unit in units.Units:
|
||||||
|
if unit.UnitType == 'LENGTHUNIT':
|
||||||
|
if unit.is_a('IfcSIUnit'):
|
||||||
|
bpy.context.scene.unit_settings.system = 'METRIC'
|
||||||
|
if unit.Name == 'METRE':
|
||||||
|
if not unit.Prefix:
|
||||||
|
bpy.context.scene.unit_settings.length_unit = 'METERS'
|
||||||
|
else:
|
||||||
|
bpy.context.scene.unit_settings.length_unit = f'{unit.Prefix}METERS'
|
||||||
|
else:
|
||||||
|
bpy.context.scene.unit_settings.system = 'IMPERIAL'
|
||||||
|
if unit.Name == 'inch':
|
||||||
|
bpy.context.scene.unit_settings.length_unit = 'INCHES'
|
||||||
|
elif unit.Name == 'foot':
|
||||||
|
bpy.context.scene.unit_settings.length_unit = 'FEET'
|
||||||
|
|
||||||
def create_geometric_representation_contexts(self):
|
def create_geometric_representation_contexts(self):
|
||||||
bpy.context.scene.BIMProperties.has_model_context = False
|
bpy.context.scene.BIMProperties.has_model_context = False
|
||||||
for context in self.file.by_type('IfcGeometricRepresentationContext'):
|
for context in self.file.by_type('IfcGeometricRepresentationContext'):
|
||||||
|
|||||||
Reference in New Issue
Block a user