diff --git a/doc/changelog.d/3662.fixed.md b/doc/changelog.d/3662.fixed.md new file mode 100644 index 0000000000..4e7029bdb5 --- /dev/null +++ b/doc/changelog.d/3662.fixed.md @@ -0,0 +1 @@ +fix: parsing components when too many \ No newline at end of file diff --git a/src/ansys/mapdl/core/component.py b/src/ansys/mapdl/core/component.py index 402f229338..ad03341d6b 100644 --- a/src/ansys/mapdl/core/component.py +++ b/src/ansys/mapdl/core/component.py @@ -580,13 +580,13 @@ def _parse_cmlist(cmlist: Optional[str] = None) -> Dict[str, Any]: # header # "NAME TYPE SUBCOMPONENTS" blocks = re.findall( - r"(?s)NAME\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\Z)", + r"(?s)NAME\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\*\*\*\*\*|\Z)", cmlist, flags=re.DOTALL, ) elif re.search(r"NAME\s+SELE\s+TYPE\s+SUBCOMPONENTS", cmlist): blocks = re.findall( - r"(?s)NAME\s+SELE\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\Z)", + r"(?s)NAME\s+SELE\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\*\*\*\*\*|\Z)", cmlist, flags=re.DOTALL, ) diff --git a/tests/test_component.py b/tests/test_component.py index aa790c4ff7..78ec707e78 100644 --- a/tests/test_component.py +++ b/tests/test_component.py @@ -327,3 +327,21 @@ def test__get_all_components_type(mapdl, cube_geom_and_mesh): assert comp_nodes == expected_output assert "CMELEM" not in comp_nodes assert "CMELEM2" not in comp_nodes + + +def test_parsing_too_many_components(mapdl, cleared): + mapdl.prep7() + + for i in range(1, 100): + mapdl.nsel("NONE") + mapdl.n(i, i, 0, 0) + mapdl.cm(f"node_{i:03.0f}", "NODE") + + s = mapdl.components.__str__() + assert len(mapdl.components._comp) == 99 + + assert "VERIFICATION" not in s + assert "***" not in s + assert "*****MAPDL" not in s + for i in range(1, 100): + assert re.search(f"NODE_{i:03.0f}\s+: NODE", s)