Hi Tatiana,
I've attached assembly with iLogic rules that could help you to start.
The first rule Iterates through all leaf occurrences collection.
The second rule Iterates through all referenced documents collection.
The last should be more efficient if your assembly includes a lot of copies of parts with holes.
(I did not test this idea though).
Both Main methods call the same function GetHolesQty which returns the number of holes in the specified part component definition.
Please note that this function cannot work with nested feature patterns.

Approach 1. Iterates through all leaf occurrences collection.
Sub Main()
Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim N As Integer = 0 'holes counter
For Each oOcc As ComponentOccurrence In oAsmDef.Occurrences.AllLeafOccurrences
If Not oOcc.Suppressed Then
If oOcc.DefinitionDocumentType = kPartDocumentObject Then
Dim oDef As PartComponentDefinition = oOcc.Definition
N += GetHolesQty(oDef)
End If
End If
Next
Beep
MsgBox ("The number of holes in the current part is: " & N)
End Sub
Approach 2. Iterates through all referenced documents collection.
Sub Main()
Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oOccs As ComponentOccurrences = oAsmDef.Occurrences
Dim N As Integer = 0 'holes counter
For Each oDoc As Inventor.Document In oAsmDoc.AllReferencedDocuments
If TypeOf oDoc Is PartDocument Then
Dim m As Integer = GetHolesQty(oDoc.ComponentDefinition)
N = N + m * oOccs.AllReferencedOccurrences(oDoc).Count
End If
Next
Beep
MsgBox ("The number of holes in the current part is: " & N)
End Sub
'''Calculates holes in the part document
'''Be careful: nested patterns are not analyzed!
Function GetHolesQty(ByVal oDef As PartComponentDefinition) As Integer
Dim N As Integer = 0 'counter
Dim oHoles As HoleFeatures = oDef.Features.HoleFeatures
For Each oH As HoleFeature In oHoles
If Not oH.Suppressed Then
N += oH.HoleCenterPoints.Count
End If
Next
'have we any rectangular patterns ?
Dim oRectPatterns As RectangularPatternFeatures
oRectPatterns = oDef.Features.RectangularPatternFeatures
For Each oRPF As RectangularPatternFeature In oRectPatterns
Dim m As Integer = 0
If Not oRPF.Suppressed Then
If (TypeOf oRPF.ParentFeatures.Item(1) Is HoleFeature) Then
Dim oH As HoleFeature = oRPF.ParentFeatures.Item(1)
If Not oH.Suppressed Then
For Each oFPE As FeaturePatternElement In oRPF.PatternElements
If Not oFPE.Suppressed Then m += 1
Next
End If
End If
N += m - 1
Else
N += m
End If
Next
'have we any circular patterns ?
Dim oCircPatterns As CircularPatternFeatures
oCircPatterns = oDef.Features.CircularPatternFeatures
For Each oCPF As CircularPatternFeature In oCircPatterns
Dim m As Integer = 0
If Not oCPF.Suppressed Then
If (TypeOf oCPF.ParentFeatures.Item(1) Is HoleFeature) Then
Dim oH As HoleFeature = oCPF.ParentFeatures.Item(1)
If Not oH.Suppressed Then
For Each oFPE As FeaturePatternElement In oCPF.PatternElements
If Not oFPE.Suppressed Then m += 1
Next
End If
End If
N += m - 1
Else
N += m
End If
Next
Return N
End Function
Cheers,
Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network