Create UI to change material definition type

This commit is contained in:
Dion Moult
2020-01-14 13:28:48 +11:00
parent 29b7b2963e
commit ef919ab431
3 changed files with 23 additions and 6 deletions
@@ -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'])
+13
View File
@@ -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):
+3
View File
@@ -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'