How do I select only outer faces?

jwkim
jwkim Member Posts: 7
Name Dropper First Comment First Anniversary
**

Hi, Team

I'm writing code for automation in Ansys Mechanical and I need to select only the outer faces, but I am not sure how to approach it.

I would appreciate if you could give me some ideas or point me to some code that allows me to make a named selection of the outer faces.

Comments

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 345
    25 Answers 100 Comments 25 Likes First Anniversary
    ✭✭✭✭
    edited February 28

    See this example. It uses code from the Bolt Tools Add On to make this easier. This code is also in the project file as a suppressed python code object in the tree. There are two examples: fully enclosed block and a block that is open on one end.

    #import from the bolt tools add on
    import sys
    BoltToolsDir = ExtAPI.ExtensionManager.GetExtensionByName("BoltTools").InstallDir
    if not BoltToolsDir in sys.path:
        sys.path.append(BoltToolsDir)
    import GeoConnectivityHelper
    GeoConnectivityHelper.Initialize(ExtAPI, Ansys)
    
    #Use the bolt tools add on module to get the face connectivity from a starting face
    StartFacesNs = ExtAPI.DataModel.GetObjectsByName("StartFaces")[0]
    StopFacesNs = ExtAPI.DataModel.GetObjectsByName("StopFaces")[0]
    
    ConnectivityMap = GeoConnectivityHelper.FaceConnectivityMap()
    ConnectivityMap.BoundaryDefinition="Explicit"
    ConnectivityMap.StartFaces=StartFacesNs.Entities
    ConnectivityMap.StopFaces=StopFacesNs.Entities
    Zones = ConnectivityMap.GetZones()
    
    i=1
    for Zone in Zones:
        #Create a new NS to represent the output
        NewNs = Model.AddNamedSelection()
        SelInfo = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
        SelInfo.Entities = Zone.Faces
        NewNs.Location = SelInfo
        NewNs.Name = "Zone Faces: "+str(i)
        i+=1