Named selection : node ids, position and node connectivity with DPF

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 734
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

Using DPF in Mechanical how can I get:

  • the ids and position of the nodes of a named selection

  • know to which elements this node is attached to (node connectivity)



Best Answer


  • Adrien Vet
    Adrien Vet Member Posts: 10
    Name Dropper Photogenic First Comment
    edited June 2023


    What is corresponding to "ns_op.inputs.requested_location.Connect('Nodal')" ?

    I mean, what have I to write inside Connect(...) ?

    If I want all the elements ids, it deosn't work when i write ns_op.inputs.requested_location.Connect('Element') or ns_op.inputs.requested_location.Connect('Elemental').



  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 240
    First Anniversary First Comment 5 Likes Ansys Employee

    This is also a helpful function to convert any selection type in Mechanical to Node Ids (does not need dpf). You can then use this line to make a dpf mesh scoping:

    def ConvertToNodeIds(SelectionData, SelectionType=None):
        Convert a given Selection Info, (or list of ent/id and Selection Type) to list of Node Ids
            SelectionType (Ansys.ACT.Interfaces.Common.SelectionTypeEnum)
                if SelectionType is used, then SelInfo arg is a list of Ids
            List of node ids
        SelInfo=CreateSelInfo(SelectionData, SelectionType)
        Mesh = ExtAPI.DataModel.MeshDataByName("Global")
        SelTypeStr = str(SelInfo.SelectionType)
        if SelTypeStr == "GeometryEntities":
            Ids = set()
            for Id in SelInfo.Ids:
                MeshRegion = Mesh.MeshRegionById(Id)
        elif SelTypeStr == "MeshNodes":
            Ids= list(SelInfo.Ids)
        elif SelTypeStr == "MeshElements":
            Ids= list(ExtAPI.DataModel.MeshDataByName("Global").NodeIdsFromElementIds(SelInfo.Ids))
        elif SelTypeStr == "MeshElementFaces":
            Ids = set()
            for id,index in zip(SelInfo.Ids, SelInfo.ElementFaceIndices):
                el_face = Ansys.ACT.Common.Mesh.ElementFaceWrapper(Mesh, Mesh.ElementById(id), index)
            Ids= list(Ids)
        return Ids