Is there any good way to use code check if the geometry is Visible?

ZZ.tang
ZZ.tang Member Posts: 20
10 Comments Name Dropper
**

ANSYS mechanical
version 2021r2 & 2023R1

Is there any good way to use code check if a geometry is Visible?
The geometries include the body\face\edge.

Tagged:

Comments

  • AlexGh
    AlexGh Member Posts: 26
    10 Comments First Answer Name Dropper
    **

    Hi ZZ.tang!
    For example, like this:

    # body: Ansys.ACT.Automation.Mechanical.Body
    body = ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.Body)[0]
    isBodyVisible = body.Visible
    body.Visible = True # Show body
    body.Visible = False # Hide body
    
    # part: Ansys.ACT.Automation.Mechanical.Part
    part = ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.Part)[0]
    isPartVisible = part.Visible
    part.Visible = True # Show part
    part.Visible = False # Hide part
    
  • Erik Kostson
    Erik Kostson Member, Employee Posts: 247
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    Hello

    not sure what the question is here (perhaps there is none :))?

    If you are having any issues with the script, or u would like to ask something, please expand and explain a bit more in detail and we will then try and help.

    thank you

    Erik

  • ZZ.tang
    ZZ.tang Member Posts: 20
    10 Comments Name Dropper
    **

    My question> @AlexGh said:

    Hi ZZ.tang!
    For example, like this:

    # body: Ansys.ACT.Automation.Mechanical.Body
    body = ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.Body)[0]
    isBodyVisible = body.Visible
    body.Visible = True # Show body
    body.Visible = False # Hide body
    
    # part: Ansys.ACT.Automation.Mechanical.Part
    part = ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.Part)[0]
    isPartVisible = part.Visible
    part.Visible = True # Show part
    part.Visible = False # Hide part
    

    Thanks AlexGh Eric,

    let me try to explain my question more clearly.
    I'm trying to use "DataModel.GeoData.GeoEntityById(geoid)"
    to get a "Ansys.ACT.Common.Geometry.GeoBodyWrapper \ GeoFaceWrapper \GeoEdgeWrapper"
    I want to know if the Geo****Wrapper has been hidden in GUI.

    Or is there any good way to check if a "Geo****Wrapper" is belonging to a "DataModelObjectCategory"

    Thanks!

  • Erik Kostson
    Erik Kostson Member, Employee Posts: 247
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited October 25

    Hi

    A geobody does not have such property (check if visible - see below link on the difference between the 2 bodies which can be confusing)

    One can though combine the above script, and getting the Tree body from a Geo body , and then checking if the Tree body is visible or not (above script).

    (see below the difference between the two type of bodies and how to obtain them)

    https://discuss.ansys.com/discussion/2288/whats-the-difference-between-tree-geometry-and-geodata-in-mechanical-api

    All the best

    Erik

  • ZZ.tang
    ZZ.tang Member Posts: 20
    10 Comments Name Dropper
    **

    @Erik Kostson said:
    Hi

    A geobody does not have such property (check if visible - see below link on the difference between the 2 bodies which can be confusing)

    One can though combine the above script, and getting the Tree body from a Geo body , and then checking if the Tree body is visible or not (above script).

    (see below the difference between the two type of bodies and how to obtain them)

    https://discuss.ansys.com/discussion/2288/whats-the-difference-between-tree-geometry-and-geodata-in-mechanical-api

    All the best

    Erik

    Thanks Erik, this is very helpful for me.