You can loop over bodies/faces like this:
Dim doc As PartDocument = ThisDoc.Document
Dim bodies = doc.ComponentDefinition.SurfaceBodies
Dim smallestFaceArea As Double = Double.MaxValue
Dim smallestFace As Face = Nothing
For Each body As SurfaceBody In bodies
For Each face As Face In body.Faces
Dim area = face.Evaluator.Area
If (smallestFaceArea > area) Then
smallestFace = face
smallestFaceArea = area
End If
Next
Next
doc.SelectSet.Clear()
doc.SelectSet.Select(smallestFace)
or if you don't want to loop, then this is also possible:
Dim doc As PartDocument = ThisDoc.Document
Dim smallestFace = doc.ComponentDefinition.SurfaceBodies.
Cast(Of SurfaceBody).
SelectMany(Of Face)(Function(f) f.Faces.Cast(Of Face)).
Aggregate(Function(face, nextFace) If(face.Evaluator.Area < nextFace.Evaluator.Area, face, nextFace))
doc.SelectSet.Clear()
doc.SelectSet.Select(smallestFace)
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog: hjalte.nl - github.com