Skip to content

Commit 9eeb5d9

Browse files
gmalinveSamuelopez-ansysAlberto-DM
authored
get materials in project (#3886)
* get materials in design * docstring * fixes * uncomment * Update pyaedt/modules/MaterialLib.py * Update _unittest/test_03_Materials.py Co-authored-by: Samuel Lopez <[email protected]> * Update _unittest/test_03_Materials.py Co-authored-by: Samuel Lopez <[email protected]> * Update pyaedt/modules/MaterialLib.py Co-authored-by: Samuel Lopez <[email protected]> * Update pyaedt/modules/MaterialLib.py --------- Co-authored-by: Samuel Lopez <[email protected]> Co-authored-by: Alberto Di Maria <[email protected]>
1 parent d269917 commit 9eeb5d9

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

_unittest/test_03_Materials.py

+6
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,9 @@ def test_12_material_model(self):
268268
self.aedtapp["$dk"] = 3
269269
self.aedtapp["$df"] = 0.01
270270
assert mat.set_djordjevic_sarkar_model(dk="$dk", df="$df")
271+
272+
def test_13_get_materials_in_project(self):
273+
used_materials = self.aedtapp.materials.get_used_project_material_names()
274+
assert isinstance(used_materials, list)
275+
for m in [mat for mat in self.aedtapp.materials if mat.is_used]:
276+
assert m.name in used_materials

pyaedt/modules/MaterialLib.py

+16
Original file line numberDiff line numberDiff line change
@@ -852,3 +852,19 @@ def import_materials_from_excel(self, material_file):
852852
materials_added.append(new_material)
853853

854854
return materials_added
855+
856+
@pyaedt_function_handler
857+
def get_used_project_material_names(self):
858+
"""Get list of material names in current project.
859+
860+
Returns
861+
-------
862+
List of str
863+
List of material names used in the current project.
864+
865+
References
866+
----------
867+
868+
>>> oDefinitionManager.GetInUseProjectMaterialNames
869+
"""
870+
return self.odefinition_manager.GetInUseProjectMaterialNames()

0 commit comments

Comments
 (0)