From 7d976b1bc71072e98f6ae0a00ed55480063576c4 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sat, 8 Aug 2020 14:47:33 +1000 Subject: [PATCH] Add support for importing area and volume units --- src/ifcblenderexport/blenderbim/bim/import_ifc.py | 7 +++++++ src/ifcblenderexport/blenderbim/bim/prop.py | 2 ++ src/ifcblenderexport/blenderbim/bim/ui.py | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ifcblenderexport/blenderbim/bim/import_ifc.py b/src/ifcblenderexport/blenderbim/bim/import_ifc.py index ee4b13816f..78d63bf38e 100644 --- a/src/ifcblenderexport/blenderbim/bim/import_ifc.py +++ b/src/ifcblenderexport/blenderbim/bim/import_ifc.py @@ -494,6 +494,7 @@ class IfcImporter(): products.extend(self.get_products_from_shape_representation(inverse_element)) return products + # TODO migrate to utility def replace_attribute(self, element, old, new): for i, attribute in enumerate(element): if attribute == old: @@ -1358,6 +1359,12 @@ class IfcImporter(): bpy.context.scene.unit_settings.length_unit = 'INCHES' elif unit.Name == 'foot': bpy.context.scene.unit_settings.length_unit = 'FEET' + elif unit.is_a('IfcNamedUnit') and unit.UnitType == 'AREAUNIT': + bpy.context.scene.BIMProperties.area_unit = '{}{}'.format( + unit.Prefix + '/' if hasattr(unit, 'Prefix') and unit.Prefix else '', unit.Name) + elif unit.is_a('IfcNamedUnit') and unit.UnitType == 'VOLUMEUNIT': + bpy.context.scene.BIMProperties.volume_unit = '{}{}'.format( + unit.Prefix + '/' if hasattr(unit, 'Prefix') and unit.Prefix else '', unit.Name) def create_geometric_representation_contexts(self): bpy.context.scene.BIMProperties.has_model_context = False diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index b6db0dae55..3021142234 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -1088,6 +1088,8 @@ class BIMProperties(PropertyGroup): ifc_patch_output: StringProperty(default='', name='IFC Patch Output IFC') ifc_patch_args: StringProperty(default='', name='Arguments') qto_result: StringProperty(default='', name='Qto Result') + area_unit: StringProperty(default='', name='Area Unit') + volume_unit: StringProperty(default='', name='Volume Unit') class BCFProperties(PropertyGroup): diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 70f6fb211a..72c3294c69 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -487,15 +487,23 @@ class BIM_PT_psets(Panel): class BIM_PT_qto(Panel): bl_label = 'IFC Quantity Take-off' bl_idname = 'BIM_PT_qto' - #bl_options = {'DEFAULT_CLOSED'} + bl_options = {'DEFAULT_CLOSED'} bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = 'scene' def draw(self, context): layout = self.layout + layout.use_property_split = True props = context.scene.BIMProperties + row = layout.row() + layout.label(text="Units:") + row = layout.row() + row.prop(props, 'area_unit') + row = layout.row() + row.prop(props, 'volume_unit') + row = layout.row() layout.label(text="Results:") row = layout.row()