Here is a starting point for you. It is working to find circular edges in the face selected. I know in your case that edge may be deeper but that should me a minor modification to get that to work. See if that works and post back with any question.
Sub Main
Dim oAssyDoc As AssemblyDocument = ThisDoc.Document
Dim oAssyDef As AssemblyComponentDefinition = oAssyDoc.ComponentDefinition
Dim oFace As Face = ThisApplication.CommandManager.Pick _
(SelectionFilterEnum.kPartFaceFilter, _
"Select an occurrence with holes, Press Esc when Complete")
If oFace Is Nothing Then Exit Sub 'User canceled so Exit Out
Dim oOcc1 As ComponentOccurrence = oFace.Parent.Parent
Dim i As Integer = 0 'Start Index for edge naming
For Each oEdge As Edge In oFace.Edges
i = i + 1
HighlightEntities(oOcc1, oEdge, i) 'Use tool to identify edges
If oEdge.GeometryType = CurveTypeEnum.kCircleCurve Then 'Check it is a circle so likely a hole
Dim oCircle As Circle = oEdge.Geometry 'Get a Hole selection from the user
Dim Hole_Dia As Double = Round(((oCircle.Radius * 2)* 10), 2)'Converted to Diameter and mm'
If Hole_Dia = 10 mm Then
Dim oScrew = Components.AddContentCenterPart("","Fasteners:Bolts:Countersunk","DIN 7991", "M8x60")
Dim oOccScrew As ComponentOccurrence = oScrew.Occurrence
Dim ScrewDef As PartComponentDefinition = oOccScrew.Definition
Dim oEdge1 As Edge = ScrewDef.SurfaceBodies.Item(1).Edges(3)'Select Specific edge of screw
'HighlightEntities(oOccScrew, oEdge1, i)'Use tool to identify edges
Dim oEdgeProxy1 As EdgeProxy 'Create a proxy edge
Call oOccScrew.CreateGeometryProxy(oEdge1, oEdgeProxy1)
Dim oEdgeProxy As EdgeProxy ' Circle Edge Proxy of the part
Call oOcc1.CreateGeometryProxy(oEdge, oEdgeProxy)
'Create the insert Constraint between the parts.
Dim oInsert As InsertConstraint = oAssyDef.Constraints.AddInsertConstraint _
(oEdgeProxy1, oEdgeProxy, False, -3 / 10)
End If
End If
Next
End Sub
Sub HighlightEntities(oOcc As ComponentOccurrence,obj As Object,i As Integer)
Dim oDoc As Document = ThisDoc.Document
Dim objProxy As Object
oOcc.CreateGeometryProxy(obj, objProxy)
Dim oSet1 As HighlightSet = oDoc.CreateHighlightSet 'Create a highlight Set.
Dim oSet2 As HighlightSet = oDoc.CreateHighlightSet 'Create a highlight Set.
If Not obj.GeometryType = CurveTypeEnum.kCircleCurve Then 'Check it is a circle so likely a hole
oSet1.AddItem(objProxy) 'Add the first face to the highlight set.
oSet1.Color = ThisApplication.TransientObjects.CreateColor(230, 31, 31) 'Change the color of the highlight set to green.
Else
oSet2.AddItem(objProxy)' Add the first face to the highlight set.
oSet2.Color = ThisApplication.TransientObjects.CreateColor(0, 255, 0) 'Change the color of the highlight set to green.
End If
ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPointEntities, "Object Check:" & i & ". Press Esc to Move to Next Object")
'[Pause Inventor between selections'alternative is use a message box
'https://ekinssolutions.com/selecting-multiple-entities-using-pick-in-inventor/
System.Windows.Forms.Application.DoEvents()
System.Threading.Thread.Sleep(200)
System.Windows.Forms.Application.DoEvents()
']
End Sub
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan