diff --git a/doc/changelog.d/3636.miscellaneous.md b/doc/changelog.d/3636.miscellaneous.md new file mode 100644 index 0000000000..5d0e245a47 --- /dev/null +++ b/doc/changelog.d/3636.miscellaneous.md @@ -0,0 +1 @@ +feat: node/element selection commands returning selected ids \ No newline at end of file diff --git a/src/ansys/mapdl/core/commands.py b/src/ansys/mapdl/core/commands.py index c6c7c489cf..935284e19d 100644 --- a/src/ansys/mapdl/core/commands.py +++ b/src/ansys/mapdl/core/commands.py @@ -193,6 +193,8 @@ "LSEL", "ASEL", "VSEL", + "ESLN", + "NSLE", ] diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index 4201a0fc3d..ff50e89414 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -1321,6 +1321,10 @@ def wrap_xsel_function_output(method): return self.geometry.anum elif name == "VSEL": return self.geometry.vnum + elif name == "ESLN": + return self.mesh.enum + elif name == "NSLE": + return self.mesh.nnum else: return None diff --git a/tests/conftest.py b/tests/conftest.py index deebfcaa27..3f87e5fedd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1157,6 +1157,24 @@ def create_geometry(mapdl): return areas, keypoints +@pytest.fixture(scope="function") +def two_dimensional_mesh(mapdl, cleared): + length = 4 + height = 1 + thickness = 0.2 + mesh_size = 0.1 + + mapdl.prep7() + + mapdl.r(r1=thickness) + mapdl.et(1, "PLANE182", kop3=3, kop6=0) + mapdl.rectng(0, length, 0, height) + mapdl.mshkey(1) + mapdl.mshape(0, "2D") + mapdl.esize(mesh_size) + mapdl.amesh("ALL") + + @pytest.fixture def query(mapdl, cleared): return mapdl.queries diff --git a/tests/test_mesh_grpc.py b/tests/test_mesh_grpc.py index a0aaf421f7..e914974b22 100644 --- a/tests/test_mesh_grpc.py +++ b/tests/test_mesh_grpc.py @@ -317,3 +317,42 @@ def test_nodal_rotation(mapdl, cleared): ] ) assert np.allclose(nrotation_ref, nrotations[:7, :]) + + +def test_esln(mapdl, two_dimensional_mesh): + mapdl.nsel("S", "LOC", "X", 0) + selected_ids = mapdl.esln("S", 0) + expected_selected_ids = np.array([1, 41, 81, 121, 161, 201, 241, 281, 321, 361]) + assert all(selected_ids == expected_selected_ids) + + +def test_nsle(mapdl, two_dimensional_mesh): + mapdl.esel("S", "CENT", "X", 0, 0.1) + selected_ids = mapdl.nsle("S") + expected_selected_ids = np.array( + [ + 1, + 3, + 52, + 91, + 92, + 93, + 94, + 95, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + ] + ) + assert all(selected_ids == expected_selected_ids)