Only allow material assignment if we have available materials to assign. See #1222.

This commit is contained in:
Dion Moult
2021-01-26 20:01:16 +11:00
parent 447a7a0eb2
commit 4527d3a96e
3 changed files with 15 additions and 0 deletions
@@ -31,25 +31,33 @@ class Data:
@classmethod
def load_materials(cls):
cls.materials = {}
cls.load_element("IfcMaterial", cls.materials)
@classmethod
def load_constituents(cls):
cls.constituent_sets = {}
cls.constituents = {}
cls.load_element("IfcMaterialConstituent", cls.constituents)
cls.load_element("IfcMaterialConstituentSet", cls.constituent_sets)
@classmethod
def load_layers(cls):
cls.layer_sets = {}
cls.layers = {}
cls.load_element("IfcMaterialLayer", cls.layers)
cls.load_element("IfcMaterialLayerSet", cls.layer_sets)
@classmethod
def load_profiles(cls):
cls.profile_sets = {}
cls.profiles = {}
cls.load_element("IfcMaterialProfile", cls.profiles)
cls.load_element("IfcMaterialProfileSet", cls.profile_sets)
@classmethod
def load_lists(cls):
cls.lists = {}
cls.load_element("IfcMaterialList", cls.lists)
@classmethod
@@ -25,6 +25,7 @@ class AddMaterial(bpy.types.Operator):
self.file = IfcStore.get_file()
result = add_material.Usecase(self.file, {"Name": obj.name}).execute()
obj.BIMObjectProperties.ifc_definition_id = result.id()
Data.load()
return {"FINISHED"}
@@ -40,6 +41,7 @@ class RemoveMaterial(bpy.types.Operator):
self.file, {"material": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)}
).execute()
obj.BIMObjectProperties.ifc_definition_id = 0
Data.load()
return {"FINISHED"}
@@ -39,6 +39,11 @@ class BIM_PT_object_material(Panel):
Data.load(self.oprops.ifc_definition_id)
self.product_data = Data.products[self.oprops.ifc_definition_id]
if not Data.materials:
row = self.layout.row()
row.label(text="No Materials Available")
return
if self.product_data:
if self.product_data["type"] == "IfcMaterialConstituentSet":
self.material_set_data = Data.constituent_sets[self.product_data["id"]]