mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
Create UI to change material definition type
This commit is contained in:
@@ -423,9 +423,9 @@ class IfcParser():
|
|||||||
for slot in obj.material_slots:
|
for slot in obj.material_slots:
|
||||||
if slot.link == 'OBJECT':
|
if slot.link == 'OBJECT':
|
||||||
continue
|
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)
|
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(
|
self.rel_associates_material_constituent_set.setdefault(self.product_index, []).append(
|
||||||
slot.material.name)
|
slot.material.name)
|
||||||
else:
|
else:
|
||||||
@@ -775,14 +775,15 @@ class IfcParser():
|
|||||||
'layer_ifc': None,
|
'layer_ifc': None,
|
||||||
'constituent_ifc': None,
|
'constituent_ifc': None,
|
||||||
'raw': slot.material,
|
'raw': slot.material,
|
||||||
'is_material_layer_set': 'IsMaterialLayerSet' in obj.keys(),
|
'material_type': obj.BIMObjectProperties.material_type,
|
||||||
'is_material_constituent_set': 'IsMaterialConstituentSet' in obj.keys(),
|
|
||||||
'attributes': {'Name': slot.material.name},
|
'attributes': {'Name': slot.material.name},
|
||||||
|
# TODO: turn into non-custom attributes
|
||||||
'layer_attributes': {
|
'layer_attributes': {
|
||||||
key[3:]: slot.material[key]
|
key[3:]: slot.material[key]
|
||||||
for key in slot.material.keys()
|
for key in slot.material.keys()
|
||||||
if key[0:3] == 'Ifc'
|
if key[0:3] == 'Ifc'
|
||||||
},
|
},
|
||||||
|
# TODO: turn into non-custom attributes
|
||||||
'constituent_attributes': {
|
'constituent_attributes': {
|
||||||
key[3:]: slot.material[key]
|
key[3:]: slot.material[key]
|
||||||
for key in slot.material.keys()
|
for key in slot.material.keys()
|
||||||
@@ -1450,11 +1451,11 @@ class IfcExporter():
|
|||||||
self.create_material_psets(material)
|
self.create_material_psets(material)
|
||||||
self.file.createIfcMaterialDefinitionRepresentation(
|
self.file.createIfcMaterialDefinitionRepresentation(
|
||||||
material['raw'].name, None, [styled_representation], material['ifc'])
|
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_attributes']['Material'] = material['ifc']
|
||||||
material['layer_ifc'] = self.file.create_entity('IfcMaterialLayer',
|
material['layer_ifc'] = self.file.create_entity('IfcMaterialLayer',
|
||||||
**material['layer_attributes'])
|
**material['layer_attributes'])
|
||||||
elif material['is_material_constituent_set']:
|
elif material['material_type'] == 'IfcMaterialConstituentSet':
|
||||||
material['constituent_attributes']['Material'] = material['ifc']
|
material['constituent_attributes']['Material'] = material['ifc']
|
||||||
material['constituent_ifc'] = self.file.create_entity('IfcMaterialConstituent',
|
material['constituent_ifc'] = self.file.create_entity('IfcMaterialConstituent',
|
||||||
**material['constituent_attributes'])
|
**material['constituent_attributes'])
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ classification_enum = []
|
|||||||
reference_enum = []
|
reference_enum = []
|
||||||
attributes_enum = []
|
attributes_enum = []
|
||||||
documents_enum = []
|
documents_enum = []
|
||||||
|
materialtypes_enum = []
|
||||||
contexts_enum = []
|
contexts_enum = []
|
||||||
subcontexts_enum = []
|
subcontexts_enum = []
|
||||||
target_views_enum = []
|
target_views_enum = []
|
||||||
@@ -213,6 +214,17 @@ def getApplicableDocuments(self, context):
|
|||||||
return documents_enum
|
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):
|
def getSubcontexts(self, context):
|
||||||
global subcontexts_enum
|
global subcontexts_enum
|
||||||
subcontexts_enum.clear()
|
subcontexts_enum.clear()
|
||||||
@@ -362,6 +374,7 @@ class BIMObjectProperties(PropertyGroup):
|
|||||||
documents: CollectionProperty(name="Documents", type=Document)
|
documents: CollectionProperty(name="Documents", type=Document)
|
||||||
applicable_documents: EnumProperty(items=getApplicableDocuments, name="Available Documents")
|
applicable_documents: EnumProperty(items=getApplicableDocuments, name="Available Documents")
|
||||||
classifications: CollectionProperty(name="Classifications", type=Classification)
|
classifications: CollectionProperty(name="Classifications", type=Classification)
|
||||||
|
material_type: EnumProperty(items=getMaterialTypes, name="Material Type")
|
||||||
|
|
||||||
|
|
||||||
class BIMMaterialProperties(PropertyGroup):
|
class BIMMaterialProperties(PropertyGroup):
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ class BIM_PT_object(Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(props, 'classifications')
|
row.prop(props, 'classifications')
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(props, 'material_type')
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_mesh(Panel):
|
class BIM_PT_mesh(Panel):
|
||||||
bl_label = 'IFC Representations'
|
bl_label = 'IFC Representations'
|
||||||
|
|||||||
Reference in New Issue
Block a user