From ef919ab4311a5a9598f6ddfac107056ecd6a50a4 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 14 Jan 2020 13:28:48 +1100 Subject: [PATCH] Create UI to change material definition type --- src/ifcblenderexport/blenderbim/export_ifc.py | 13 +++++++------ src/ifcblenderexport/blenderbim/prop.py | 13 +++++++++++++ src/ifcblenderexport/blenderbim/ui.py | 3 +++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/export_ifc.py b/src/ifcblenderexport/blenderbim/export_ifc.py index 3bdb9919c1..6bda64fd5e 100644 --- a/src/ifcblenderexport/blenderbim/export_ifc.py +++ b/src/ifcblenderexport/blenderbim/export_ifc.py @@ -423,9 +423,9 @@ class IfcParser(): for slot in obj.material_slots: if slot.link == 'OBJECT': continue - if 'IsMaterialLayerSet' in obj: + if obj.BIMObjectProperties.material_type == 'IfcMaterialLayerSet': self.rel_associates_material_layer_set.setdefault(self.product_index, []).append(slot.material.name) - elif 'IsMaterialConstituentSet' in obj: + elif obj.BIMObjectProperties.material_type == 'IfcMaterialConstituentSet': self.rel_associates_material_constituent_set.setdefault(self.product_index, []).append( slot.material.name) else: @@ -775,14 +775,15 @@ class IfcParser(): 'layer_ifc': None, 'constituent_ifc': None, 'raw': slot.material, - 'is_material_layer_set': 'IsMaterialLayerSet' in obj.keys(), - 'is_material_constituent_set': 'IsMaterialConstituentSet' in obj.keys(), + 'material_type': obj.BIMObjectProperties.material_type, 'attributes': {'Name': slot.material.name}, + # TODO: turn into non-custom attributes 'layer_attributes': { key[3:]: slot.material[key] for key in slot.material.keys() if key[0:3] == 'Ifc' }, + # TODO: turn into non-custom attributes 'constituent_attributes': { key[3:]: slot.material[key] for key in slot.material.keys() @@ -1450,11 +1451,11 @@ class IfcExporter(): self.create_material_psets(material) self.file.createIfcMaterialDefinitionRepresentation( material['raw'].name, None, [styled_representation], material['ifc']) - if material['is_material_layer_set']: + if material['material_type'] == 'IfcMaterialLayerSet': material['layer_attributes']['Material'] = material['ifc'] material['layer_ifc'] = self.file.create_entity('IfcMaterialLayer', **material['layer_attributes']) - elif material['is_material_constituent_set']: + elif material['material_type'] == 'IfcMaterialConstituentSet': material['constituent_attributes']['Material'] = material['ifc'] material['constituent_ifc'] = self.file.create_entity('IfcMaterialConstituent', **material['constituent_attributes']) diff --git a/src/ifcblenderexport/blenderbim/prop.py b/src/ifcblenderexport/blenderbim/prop.py index 60f8e01b05..ed166d26c7 100644 --- a/src/ifcblenderexport/blenderbim/prop.py +++ b/src/ifcblenderexport/blenderbim/prop.py @@ -31,6 +31,7 @@ classification_enum = [] reference_enum = [] attributes_enum = [] documents_enum = [] +materialtypes_enum = [] contexts_enum = [] subcontexts_enum = [] target_views_enum = [] @@ -213,6 +214,17 @@ def getApplicableDocuments(self, context): return documents_enum +def getMaterialTypes(self, context): + global materialtypes_enum + materialtypes_enum.clear() + materialtypes_enum = [(m, m, '') for m in [ + 'IfcMaterial', + 'IfcMaterialConstituentSet', + 'IfcMaterialLayerSet', + 'IfcMaterialProfileSet']] + return materialtypes_enum + + def getSubcontexts(self, context): global subcontexts_enum subcontexts_enum.clear() @@ -362,6 +374,7 @@ class BIMObjectProperties(PropertyGroup): documents: CollectionProperty(name="Documents", type=Document) applicable_documents: EnumProperty(items=getApplicableDocuments, name="Available Documents") classifications: CollectionProperty(name="Classifications", type=Classification) + material_type: EnumProperty(items=getMaterialTypes, name="Material Type") class BIMMaterialProperties(PropertyGroup): diff --git a/src/ifcblenderexport/blenderbim/ui.py b/src/ifcblenderexport/blenderbim/ui.py index 3a687556ce..2db12f7eec 100644 --- a/src/ifcblenderexport/blenderbim/ui.py +++ b/src/ifcblenderexport/blenderbim/ui.py @@ -81,6 +81,9 @@ class BIM_PT_object(Panel): row = layout.row() row.prop(props, 'classifications') + row = layout.row() + row.prop(props, 'material_type') + class BIM_PT_mesh(Panel): bl_label = 'IFC Representations'