How do I check if two edges in a named selection are connected?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 389
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
edited June 2023 in Structures

How do I check if two edges in a named selection are connected?

Tagged:

Answers

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 389
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    Answer ✓

    You check for a common Vertex ID by retrieving the Vertex from EdgeWrapper. The following code expects a named selection with 2 edges called "EDGES"

    # Get both edges
    edges = ExtAPI.DataModel.GetObjectsByName("EDGES")[0]
    
    # Get Geo Data
    geo_data = ExtAPI.DataModel.Project.Model.Analyses[0].GeoData
    
    # Store all vertex ids in a list
    edge_vertices = [vertex.Id for edge_id in edges.Ids for vertex in geo_data.GeoEntityById(edge_id).Vertices]
    
    # Check if there is a duplicate entry
    if len(set(edge_vertices)) == len(edge_vertices):
        print("Edges are discontinuous")
    else:
        print("Edges are continuous")