mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-31 00:46:36 +00:00
show error message removing material that is used in material sets
previously it wasn't showing anything when you would try to remove a material
This commit is contained in:
@@ -151,7 +151,10 @@ class RemoveMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
material: bpy.props.IntProperty()
|
material: bpy.props.IntProperty()
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
core.remove_material(tool.Ifc, tool.Material, tool.Style, material=tool.Ifc.get().by_id(self.material))
|
res = core.remove_material(tool.Ifc, tool.Material, tool.Style, material=tool.Ifc.get().by_id(self.material))
|
||||||
|
if not res:
|
||||||
|
self.report({"ERROR"}, "Material is used in material sets and cannot be removed.")
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
|
||||||
class RemoveMaterialSet(bpy.types.Operator, tool.Ifc.Operator):
|
class RemoveMaterialSet(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
|
|||||||
@@ -43,9 +43,11 @@ def add_material_set(ifc, material, set_type=None):
|
|||||||
return ifc_material
|
return ifc_material
|
||||||
|
|
||||||
|
|
||||||
def remove_material(ifc, material_tool, style, material=None):
|
def remove_material(ifc, material_tool, style, material=None) -> bool:
|
||||||
|
"""returns True after deleting False,\n
|
||||||
|
returns False if material used in material sets and cannot be removed"""
|
||||||
if material_tool.is_material_used_in_sets(material):
|
if material_tool.is_material_used_in_sets(material):
|
||||||
return
|
return False
|
||||||
obj = ifc.get_object(material)
|
obj = ifc.get_object(material)
|
||||||
ifc.unlink(element=material)
|
ifc.unlink(element=material)
|
||||||
ifc.run("material.remove_material", material=material)
|
ifc.run("material.remove_material", material=material)
|
||||||
@@ -53,6 +55,7 @@ def remove_material(ifc, material_tool, style, material=None):
|
|||||||
material_tool.delete_object(obj)
|
material_tool.delete_object(obj)
|
||||||
if material_tool.is_editing_materials():
|
if material_tool.is_editing_materials():
|
||||||
material_tool.import_material_definitions(material_tool.get_active_material_type())
|
material_tool.import_material_definitions(material_tool.get_active_material_type())
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def remove_material_set(ifc, material_tool, material=None):
|
def remove_material_set(ifc, material_tool, material=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user