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: 

How to tell if two faces meet in an 'inwards' or 'outwards' edge?

Message 1 of 3
189 Views, 2 Replies

How to tell if two faces meet in an 'inwards' or 'outwards' edge?

Screenshot 2023-02-07 at 17.38.18.pngHi,


I'm trying tell the difference between Edge 1 and Edge 2 on the screenshot.


My first idea was to measure the angle between them and see which was larger. But the api returns 90 degrees / 1.57 radians between both A and B and B and C. Was hoping for 270 degrees in the case of Edge 1.


Any other way?


My code:





def get_angle_between_faces(app, ui):
    import math
    face1 = ui.selectEntity('Select face 1', 'PlanarFaces').entity
    face2 = ui.selectEntity('Select face 2', 'PlanarFaces').entity
    angle = math.degrees(app.measureManager.measureAngle(face1, face2).value)

    # [Fusion 360 Help | Measure Sample | Autodesk](
    print(f'Angle between the two faces: {angle}')

    # [Fusion 360 Help | SurfaceEvaluator.getNormalAtPoint Method | Autodesk](
    faceEval1 = face1.evaluator
    (success, normal1) = faceEval1.getNormalAtPoint(face1.pointOnFace)
    faceEval2 = face2.evaluator
    (success, normal2) = faceEval2.getNormalAtPoint(face2.pointOnFace)

    angle_between_normals = normal1.angleTo(normal2)





What are the correct terms for inwards and outwards corners btw?




Message 2 of 3
in reply to: tiktuk

It's a bit tricky to figure out, but here's a function I wrote a while ago that does it. You pass in the edge that connects to planar faces, and it returns the angle between them. In your example, edge1 will return 270 degrees and edge2 will return 90 degrees.


# Measures the angle between two planar faces that share the input edge.
# The angle is measured with respect to the exterior of the face so that
# an internal corner will be 90 deg and and external corner will be 270 deg.
def angleBetweenFaces(edge):
        if edge.faces.count == 2:
            # Get the faces that connect along the input edge.
            face1 = edge.faces.item(0)
            face2 = edge.faces.item(1)       
            # Get the middle of the edge.
            edgeEval = adsk.core.CurveEvaluator3D.cast(edge.evaluator)
            (_, minParam, maxParam) = edgeEval.getParameterExtents()
            midParam = (minParam + maxParam)/2
            (_, midPoint) = edgeEval.getPointAtParameter(midParam)
            # Get the normal of each face at the edge center.
            ret = face1.evaluator.getNormalAtPoint(midPoint)
            normal1 = ret[1]
            ret = face2.evaluator.getNormalAtPoint(midPoint)
            normal2 = ret[1]
            # Get the angle between the normals.       
            normalAngle = normal1.angleTo(normal2)
            # Get the co-edge of the selected edge for face1.
            if edge.coEdges.item(0).loop.face == face1:
                coEdge = edge.coEdges.item(0)
            elif edge.coEdges.item(1).loop.face == face1:
                coEdge = edge.coEdges.item(1)
            # Create a vector that represents the direction of the co-edge at the midpoint of the edge.
            testParam = midParam + ((maxParam - minParam) * 0.001)
            (_, testPoint) = edgeEval.getPointAtParameter(testParam)
            edgeDir = midPoint.vectorTo(testPoint)
            if not coEdge.isOpposedToEdge:
            # Get the cross product of the face normals.
            cross = normal1.crossProduct(normal2)
            # Check to see if the cross product is in the same or opposite direction
            # of the co-edge direction.  If it's opposed then it's a convex angle.
            if edgeDir.angleTo(cross) > math.pi/2:
                angle = (math.pi * 2) - (math.pi - normalAngle)
                angle = math.pi - normalAngle
            return angle
            # This can occur for periodic surfaces and the edge where the face
            # connects to itself.  We'll assume that it's a smooth connection
            # and return 180 degrees.
            return math.pi            


Brian Ekins
Inventor and Fusion 360 API Expert
Message 3 of 3
in reply to: tiktuk

Thanks @BrianEkins, that's excellent! Exactly what I need.


PS: Thanks for Nifty Dogbones as well, saves me so much time 🙂 .

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