Search code examples
vbaautodesk-inventor

How to determine if an edge is an external corner or internal corner


I have a simple example below of a geometric shape with two edges of interest - the red edge belongs to an outer/external corner, while the blue edge belongs to an inner/internal corner.

The problem is that I can get an edge, but once I have the edge object, I want to know if it is an internal edge or an external edge.

Here's what I have tried:

  • Measuring the angle between the two normal vectors of the adjacent faces - but in both cases it returns the inner angle.
  • Taking 4 points from the middle point of the line, and moving them in 4 directions (+X. -X, +Y and -Y) then casting a ray on +ve and -ve directions, looking for the adjacent faces. The hope was that the ray would pass through the face in one combination only. However, in all cases, if the ray starts on the face, then the face is the first object detected, regardless of the direction travelled. (I may not have explained it well, but in short, using rays to look for faces won't work).
  • Other, more elaborate versions of the above attempts. But the above summarises my attempts well enough.

One option I've considered that would work is to apply a fillet (radius) to the edge. If the part volume increases, then the edge is internal, if the part volume decreases then the edge is external. The only problem with this is that actually applying a fillet to all edges and testing this will be relatively slow, so it would be more helpful to perform the same test mathematically.

My code is written in VBA for Autodesk Inventor. The 'edge' object has access to the adjacent 'face' objects and their normal vectors and some other properties. Suggestions can be either specific to Autodesk Inventor or based on general geometric principals.

Here are some references to the objects in case its helpful:

enter image description here


Solution

  • Courtesy of some help on the Inventor forums, I found 2 solutions.

    1. Draw a 'TransientGeometry' box (non-interactive object) as a unit cube on each face, with a common edge centered about the midpoint of the edge. Then use the 'box.isdisjointed' method to determine whether the two boxes overlap - if they do, then the boxes are on an internal edge, otherwise, they're on an external edge.
    2. Use 'SurfaceBodies.ConcaveEdges' property to get a list of all concave edges in the model. This is easily the most elegant solution, but unfortunately, I didn't discover it until I figured out more complex solutions.

    More details here: https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/how-to-determine-if-an-edge-belongs-to-faces-that-are-inward/m-p/12249724#M157909