Add support for importing area and volume units

This commit is contained in:
Dion Moult
2020-08-08 14:47:33 +10:00
parent 43f0f396ab
commit 7d976b1bc7
3 changed files with 18 additions and 1 deletions
@@ -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
@@ -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):
+9 -1
View File
@@ -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()