The following iLogic rule may help you. (i did not test it extensive so it might have some bugs. Test it your self before using it in production.) I know this will not count holes that are created with a "Extrude" feature. Holes that are made but are pathed (closed) by some other feature will be counted anyway.
Sub Main()
Dim numberOfHoles As Integer = 0
Dim doc As PartDocument = ThisApplication.ActiveDocument
For Each hole As HoleFeature In doc.ComponentDefinition.Features.HoleFeatures
numberOfHoles = numberOfHoles + hole.HoleCenterPoints.Count
Next
For Each pattern As RectangularPatternFeature In doc.ComponentDefinition.Features.RectangularPatternFeatures
numberOfHoles = numberOfHoles + holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count)
Next
For Each pattern As CircularPatternFeature In doc.ComponentDefinition.Features.CircularPatternFeatures
numberOfHoles = numberOfHoles + holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count)
Next
For Each pattern As MirrorFeature In doc.ComponentDefinition.Features.MirrorFeatures
numberOfHoles = numberOfHoles + holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count)
Next
For Each pattern As SketchDrivenPatternFeature In doc.ComponentDefinition.Features.SketchDrivenPatternFeatures
numberOfHoles = numberOfHoles + holesInObjectCollection(pattern.Definition.ParentFeatures, pattern.PatternElements.Count)
Next
MsgBox(numberOfHoles)
End Sub
Public Function holesInObjectCollection(objs As ObjectCollection, multiplieBy As Integer)
Dim numberOfHoles As Integer = 0
For Each Feature As Object In objs
If (TypeOf Feature Is HoleFeature) Then
Dim hole As HoleFeature = Feature
numberOfHoles = numberOfHoles + (hole.HoleCenterPoints.Count * multiplieBy) - 1
ElseIf (TypeOf Feature Is RectangularPatternFeature) Then
Dim pattern As RectangularPatternFeature = Feature
numberOfHoles = numberOfHoles + (holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count))
ElseIf (TypeOf Feature Is CircularPatternFeature) Then
Dim pattern As CircularPatternFeature = Feature
numberOfHoles = numberOfHoles + (holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count))
ElseIf (TypeOf Feature Is MirrorFeature) Then
Dim pattern As MirrorFeature = Feature
numberOfHoles = numberOfHoles + (holesInObjectCollection(pattern.ParentFeatures, pattern.PatternElements.Count))
ElseIf (TypeOf Feature Is SketchDrivenPatternFeature) Then
Dim pattern As SketchDrivenPatternFeature = Feature
numberOfHoles = numberOfHoles + (holesInObjectCollection(pattern.Definition.ParentFeatures, pattern.PatternElements.Count))
End If
Next
Return numberOfHoles
End Function
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