How to Determine Whether Two Faces Are Tangent to Each Other?

kkman
kkman Member Posts: 15
Name Dropper First Comment
**

I'm working on a script to determine whether two faces are tangent to each other in ANSYS Mechanical. While planar faces are relatively straightforward to handle using normal vector comparisons and centroid-based plane checks, I am unsure how to robustly detect tangency between more complex surface types, particularly cylindrical faces, Conical faces and Spline.

Any guidance on algorithms, heuristics, or best practices for identifying face tangency — especially for these non-planar surfaces — would be greatly appreciated.

Thank you!

Answers

  • Eric Stamper
    Eric Stamper Member, Employee Posts: 10
    Second Anniversary First Answer Name Dropper Ansys Employee
    ✭✭✭

    One simple approach could be:
    1. Grab the current selection
    2. Use Extend > Adjacent (to grab any tangent geometry)
    3. Find the difference
    E.g.,

    import toolbar
    
    # Get the current selection IDs
    current_selection_ids = set(ExtAPI.SelectionManager.CurrentSelection.Ids)
    
    # Perform adjacent selection
    toolbar.DoGraphicsAdjacentSelect(ExtAPI)
    
    # Get the new selection IDs after adjacent selection
    adjacent_selection_ids = set(ExtAPI.SelectionManager.CurrentSelection.Ids)
    
    # Find only the newly selected IDs
    new_selection_ids = list(adjacent_selection_ids - current_selection_ids)
    
    if new_selection_ids:
        # Create a new selection with only the new IDs
        selection_info = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
        selection_info.Ids = new_selection_ids
        ExtAPI.SelectionManager.NewSelection(selection_info)
    else:
        print("No new adjacent entities were selected.")
    

    I'm not sure how fast this code will run if it needs to be repeated a large number of times, but it will use Mechanical's algorithm for detecting tangency.

  • kkman
    kkman Member Posts: 15
    Name Dropper First Comment
    **

    Thank you for your response!

    However, I think there may be a misunderstanding. What I’m trying to detect is whether two faces from different bodies are tangent to each other, not just whether the selected face has adjacent (neighboring) faces that are tangent to it within the same body.

    In my case, I want to programmatically analyze the geometric relationship between two specific faces—particularly when those faces are cylindrical, conical, or spline surfaces—to determine if they are tangent (i.e., they share the same surface orientation at the point of contact, but belong to different bodies).

    Could you please advise on how to approach this type of inter-body tangency check?