diff --git a/_unittest/test_03_Materials.py b/_unittest/test_03_Materials.py index 73f141114cf..53b23a0bbf1 100644 --- a/_unittest/test_03_Materials.py +++ b/_unittest/test_03_Materials.py @@ -227,7 +227,9 @@ def test_09_non_linear_materials(self, add_app): assert app.materials["myMat"].permittivity.type == "nonlinear" assert app.materials["myMat"].permeability.bunit == "tesla" mat2 = app.materials.add_material("myMat2") + assert not mat2.is_used assert app.modeler.create_box([0, 0, 0], [10, 10, 10], matname="myMat2") + assert app.materials.material_keys["mymat2"].is_used def test_10_add_material_sweep(self): assert self.aedtapp.materials.add_material_sweep(["copper", "aluminum"], "sweep_copper") diff --git a/pyaedt/modules/Material.py b/pyaedt/modules/Material.py index b770a0fe7e7..a768baacb9a 100644 --- a/pyaedt/modules/Material.py +++ b/pyaedt/modules/Material.py @@ -1132,6 +1132,14 @@ def __init__(self, materials, name, props=None): self.mod_since_lib = self._props["ModSinceLib"] del self._props["ModSinceLib"] + @property + def is_used(self): + """Checks if a project material is in use.""" + is_used = self._omaterial_manager.IsUsed(self.name) + if is_used == 0: + return False + return True + @property def coordinate_system(self): """Material coordinate system."""