Skip to content

Have another look at the components selection #3538

Open
@germa89

Description

@germa89

Should mapdl.components retrieve all the components (selected or not)?

Because it seems a reasonable thing to do this:

if "mycomp" in mapdl.components:
     print("exists")

Tip

The following APDL commands retrieves if a components exists or not. It does not matter its selection state.

*get,comp_bool, comp, name_component, type

Example

from ansys.mapdl.core import launch_mapdl

mapdl = launch_mapdl(start_instance=False, port=50052)


mapdl.clear()
out = mapdl.input("export_to_ansys.ays")

print(mapdl.components)
assert "GROUP1" not in mapdl.components
assert "LAY_WK_ANC" not in mapdl.components
assert "LAY_WK_SPRINGS" not in mapdl.components
assert "LAY_WK_TRENCH1" in mapdl.components

mapdl.aplot()


print(mapdl.components)
assert "GROUP1" not in mapdl.components
assert "LAY_WK_ANC" not in mapdl.components
assert "LAY_WK_SPRINGS" not in mapdl.components
assert "LAY_WK_TRENCH1" in mapdl.components



"""
MAPDL Components
----------------
LAY_WK_TRENCH1                   : AREA
"""

mapdl.cmsel("all")
print(mapdl.components)

assert "GROUP1" in mapdl.components
assert "LAY_WK_ANC" in mapdl.components
assert "LAY_WK_SPRINGS" in mapdl.components
assert "LAY_WK_TRENCH1" in mapdl.components

mapdl.cmsel("S", "LAY_WK_SPRINGS")
print(mapdl.components)



mapdl.cm("mycomponent", "nodes")
mapdl.cmsel("None")

if "mycomponent" in mapdl.components:
    print("Yes")
else:
    print("No")

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprove any current implemented feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions