mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
Only allow material assignment if we have available materials to assign. See #1222.
This commit is contained in:
@@ -31,25 +31,33 @@ class Data:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_materials(cls):
|
def load_materials(cls):
|
||||||
|
cls.materials = {}
|
||||||
cls.load_element("IfcMaterial", cls.materials)
|
cls.load_element("IfcMaterial", cls.materials)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_constituents(cls):
|
def load_constituents(cls):
|
||||||
|
cls.constituent_sets = {}
|
||||||
|
cls.constituents = {}
|
||||||
cls.load_element("IfcMaterialConstituent", cls.constituents)
|
cls.load_element("IfcMaterialConstituent", cls.constituents)
|
||||||
cls.load_element("IfcMaterialConstituentSet", cls.constituent_sets)
|
cls.load_element("IfcMaterialConstituentSet", cls.constituent_sets)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_layers(cls):
|
def load_layers(cls):
|
||||||
|
cls.layer_sets = {}
|
||||||
|
cls.layers = {}
|
||||||
cls.load_element("IfcMaterialLayer", cls.layers)
|
cls.load_element("IfcMaterialLayer", cls.layers)
|
||||||
cls.load_element("IfcMaterialLayerSet", cls.layer_sets)
|
cls.load_element("IfcMaterialLayerSet", cls.layer_sets)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_profiles(cls):
|
def load_profiles(cls):
|
||||||
|
cls.profile_sets = {}
|
||||||
|
cls.profiles = {}
|
||||||
cls.load_element("IfcMaterialProfile", cls.profiles)
|
cls.load_element("IfcMaterialProfile", cls.profiles)
|
||||||
cls.load_element("IfcMaterialProfileSet", cls.profile_sets)
|
cls.load_element("IfcMaterialProfileSet", cls.profile_sets)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_lists(cls):
|
def load_lists(cls):
|
||||||
|
cls.lists = {}
|
||||||
cls.load_element("IfcMaterialList", cls.lists)
|
cls.load_element("IfcMaterialList", cls.lists)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class AddMaterial(bpy.types.Operator):
|
|||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
result = add_material.Usecase(self.file, {"Name": obj.name}).execute()
|
result = add_material.Usecase(self.file, {"Name": obj.name}).execute()
|
||||||
obj.BIMObjectProperties.ifc_definition_id = result.id()
|
obj.BIMObjectProperties.ifc_definition_id = result.id()
|
||||||
|
Data.load()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ class RemoveMaterial(bpy.types.Operator):
|
|||||||
self.file, {"material": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)}
|
self.file, {"material": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)}
|
||||||
).execute()
|
).execute()
|
||||||
obj.BIMObjectProperties.ifc_definition_id = 0
|
obj.BIMObjectProperties.ifc_definition_id = 0
|
||||||
|
Data.load()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ class BIM_PT_object_material(Panel):
|
|||||||
Data.load(self.oprops.ifc_definition_id)
|
Data.load(self.oprops.ifc_definition_id)
|
||||||
self.product_data = Data.products[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:
|
||||||
if self.product_data["type"] == "IfcMaterialConstituentSet":
|
if self.product_data["type"] == "IfcMaterialConstituentSet":
|
||||||
self.material_set_data = Data.constituent_sets[self.product_data["id"]]
|
self.material_set_data = Data.constituent_sets[self.product_data["id"]]
|
||||||
|
|||||||
Reference in New Issue
Block a user