Hey mate, I'm certainly no expert so if my solution doesn't work, I apologise in advance.
However, I think because you're in a top level assembly, and you're trying to access a feature in a sub-assembly, I believe you need to define the sub-assemblies and the component definitions first in order to access that lower level feature.
This is a rule I have which I used to explode patterns, which I believe will show you how to access the pattern feature. The other rule I have is used to see if all lower assemblies have a View Representation named "Hidden" and if it does, it will set it to active, which is used to hide my master sketch parts from the top-level assembly without needing to go turn all of them off individually. Please note, I don't take any credit for either of these, I have found bits and pieces of code and examples from the internet and modified it to make it work.
If this is of any help, please let me know 🙂
' <FireOthersImmediately>False</FireOthersImmediately>
Sub Main() ExplodePattern
'**** Define Assembly & Pattern Occurence.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oPattern As OccurrencePattern
oPatternInput = InputBox("Pattern Feature Name")
oPattern = oDoc.ComponentDefinition.OccurrencePatterns.Item(oPatternInput)
'**** Make each element dependent starting from the 2nd element.
Dim i As Integer
'**** Count the amount of elements after the 2nd.
For i = 2 To oPattern.OccurrencePatternElements.Count
'**** Make all elements "Independent".
oPattern.OccurrencePatternElements.Item(i).Independent = True
Next
'**** Delete pattern leaving only original and independent items.
oPattern.Delete
End Sub
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument
Dim oAssyCompDef As AssemblyComponentDefinition
oAssyCompDef = oAssyDoc.ComponentDefinition
Dim oOccurrences As ComponentOccurrences
oOccurrences = oAssyCompDef.Occurrences
Dim oLeafOccs As ComponentOccurrencesEnumerator
oLeafOccs = oOccurrences.AllLeafOccurrences
Dim oLeafOcc As ComponentOccurrence
For Each oLeafOcc In oLeafOccs
' DO YOUR WORK HERE
' ########## - TURN OFF VISIBILITY FOR ALL PARTS CONTAINING STRING BELOW - ###########
Dim oPDef As PartComponentDefinition = oLeafOcc.Definition
oDVRepName = "Hidden"
oDVReps = oPDef.RepresentationsManager.DesignViewRepresentations
For Each oDVRep As DesignViewRepresentation In oDVReps
If oDVRep.Name = oDVRepName Then
'Found it'
oLeafOcc.SetDesignViewRepresentation(oDVRepName, , True)
End If
Next
' ########## - END OF MY SECTION - ###########
Next