Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have another look at the components selection #3538

Open
germa89 opened this issue Nov 6, 2024 · 2 comments
Open

Have another look at the components selection #3538

germa89 opened this issue Nov 6, 2024 · 2 comments

Comments

@germa89
Copy link
Collaborator

germa89 commented Nov 6, 2024

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")
@germa89
Copy link
Collaborator Author

germa89 commented Nov 6, 2024

I need to also allow to:

len(mapdl.components)

@germa89
Copy link
Collaborator Author

germa89 commented Nov 6, 2024

Idea to check:

mapdl.components:

    # get current components
    arr = mapdl.get_component_selection()

    # select all components
    mapdl.cmsel("all")

    # check/in/print whatever action
    print(mapdl.components)
    
    # Getting back previous selection
    mapdl.select_components(arr)

It might be a problem when after components selection, we have played around with entities, unselecting or selecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant