If you only want to count cylindrical holes this ilogic rule could serve you in any part file.
Analyze the cylindrical surfaces, and then analyze their edges. If there is a deformed hole in a crease, for example, it will not count.
Dim oDoc As PartDocument = ThisDoc.Document
Dim oCD As PartComponentDefinition= oDoc.ComponentDefinition
Dim i As Integer = 0
If oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
If oCD.HasFlatPattern = False Then
oCD.Unfold
oCD.FlatPattern.ExitEdit
End If
For Each oSolid As SurfaceBody In oCD.FlatPattern.SurfaceBodies
For Each oFace As Face In oSolid.Faces
If oFace.SurfaceType = 5891 Then 'kCylinderSurface
For Each oEdge As Edge In oFace.Edges
If oEdge.GeometryType = 5124 Then 'kCircleCurve
i = i + 1
Exit For
End If
Next
End If
Next
Next
Else
For Each oSolid As SurfaceBody In oCD.SurfaceBodies
For Each oFace As Face In oSolid.Faces
If oFace.SurfaceType = 5891 Then 'kCylinderSurface
For Each oEdge As Edge In oFace.Edges
If oEdge.GeometryType = 5124 Then 'kCircleCurve
i = i + 1
Exit For
End If
Next
End If
Next
Next
End If
MessageBox.Show("Number of Holes: " & i)
I hope this helps with your problem. Regards
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn