Hi Kandentti,
Thank you for your help!
I actually did use a similar approach to your solution here. Unfortunately I do not have access to Fusion 360 currently, so I will explain my idea briefly below. (The code will require slight tweak or addition to work properly)
1. Calculate minimum distance between the faces.
app = adsk.core.Application.get()
result = app.measureManager.measureMinimumDistance(face_1: adsk.fusion.BRepFace, face_2: adsk.fusion.BRepFace)
distance = result.value
2. Check if both faces are planes.
3. If true, get the normal of the faces and calculate the angle between the normal.
#Get normal of planar faces (face.geometry.surfaceType should be 0)
f1_normal = face_1.geometry.normal
f2_normal = face_2.geometry.normal
#Check if the normal is reversed
if face_1.isParamReversed:
f1_normal.scaleBy(-1)
if face_2.isParamReversed:
f2_normal.scaleBy(-1)
#Calculate angle
angle = f1_normal.angleTo(f2_normal)
4. If the angle is 0 or 180 [degree], we can conclude that the faces are parallel.
5. The main problem here is that for measurement between parallel faces, the measurement points can lie outside of the face boundaries. Hence we check if this situation happens here.
#measureResult returned by measureManager.measureMinimumDistance also provides information about the position of measurement points
f1_point = result.positionOne
f2_point = result.positionTwo
#Now check if both points are on either face
f1_point_on_face = any([face.boundingBox.contains(f1_point) for face in [face_1, face_2]])
f2_point_on_face = any([face.boundingBox.contains(f2_point) for face in [face_1, face_2]])
if f1_point_on_face and f2_point_on_face:
return True #This indicates the measurement is actually made ON the faces
6. If the verification above failed (measurement is outside of face boundaries), measure the distances between the edges and pick the minimum. This is equivalent to the your code here.
This approach gives me the result I expected, but with a considerable amount of extra work. In addition, this brings more computational cost. I still believe that simply limiting the measurement points strictly within faces is the more efficient way to go.
Huge thank you to Kandentti for your help. In fact, you always impress me by your efficiency and quality on providing solutions.