Skip to content

Commit

Permalink
Add is used flag to material (#3854)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys authored Nov 7, 2023
1 parent db50f96 commit d9fd4fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _unittest/test_03_Materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions pyaedt/modules/Material.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit d9fd4fa

Please sign in to comment.