Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Finding which face the triangles belong to

Message 1 of 3
287 Views, 2 Replies

Finding which face the triangles belong to



Is there a way to find out which triangles in a generated mesh correspond to which BRep faces?


I'd like to have a set of faces and a corresponding set of the generated triangles for each face. I need to do this for all of the triangles, not just a single one. Of course, I can generate the mesh for each face separately, but I need the resulting mesh to be watertight/manifold and I don't believe there is any guarantee (or I can't find one Smiley Wink ) that in the seams between the meshes the same vertices will be used.


Can anyone help me with this?




Message 2 of 3
in reply to: jeremy.herbert

How about to check if the three points of each triangle are on the face? If the three points of one triangle are all on the face, the triangle is on the face. I wrote a function “isTriangleOnFace”, hope it’s helpful.


import adsk.core, adsk.fusion,, traceback

# point0, point1, point2 - Point3D object, point of triangle
# face - BRepFace object
def isTriangleOnFace(point0, point1, point2, face):
    # Get surface evaluator of the face
    eva = face.evaluator
    # Get the parameter positions that correspond to a set of points on the surface
    # If the points do not lie on the surface, the parameter of the nearest point on the surface will generally be returned
    (retVal, params) = eva.getParametersAtPoints([point0, point1, point2])
    if len(params) != 3:
        return False
    # Check if the parameters are out of the extent of the face
    if not eva.isParameterOnFace(params[0]) or not eva.isParameterOnFace(params[1]) or not eva.isParameterOnFace(params[2]):
        return False
    # The returned points should be on the face
    retPoints = None
    (retVal, retPoints) = eva.getPointsAtParameters(params)
    if len(retPoints) != 3:
        return False

    return point0.isEqualTo(retPoints[0]) and point1.isEqualTo(retPoints[1]) and point2.isEqualTo(retPoints[2])

def run(context):
    ui = None
        app = adsk.core.Application.get()
        ui  = app.userInterface
        face = ui.selectEntity("Select a BRepFace", "Faces").entity;
        triangle0 = [adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(1, 0, 0), adsk.core.Point3D.create(0, 1, 0)]
        ret = isTriangleOnFace(triangle0[0], triangle0[1], triangle0[2], face)
        ui.messageBox('isTriangleOnFace: ' + str(ret))
        if ui:



Message 3 of 3
in reply to: jeremy.herbert

Because of the way Fusion tesselates the model, you should get a watertight mesh if you go face-by-face, as long as you use the same tolerance to generate the mesh.

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report